当前位置: 首页>>代码示例>>C++>>正文


C++ Thread::GetTLD方法代码示例

本文整理汇总了C++中Thread::GetTLD方法的典型用法代码示例。如果您正苦于以下问题:C++ Thread::GetTLD方法的具体用法?C++ Thread::GetTLD怎么用?C++ Thread::GetTLD使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thread的用法示例。


在下文中一共展示了Thread::GetTLD方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AdjustThreadPool

int Processor::AdjustThreadPool(int c, int check)
{
	Thread * t;
	ThreadLocalData *tld;

	if (num == c)
		return rnum;

	num = c;
	if (rnum > c) { 
		/* First shrink the idle threads in the pool. */
		while (rnum > c) {
			t = NextIdleThreadFromPool();
			if (t == NULL)
				break;

			tld = t->GetTLD();
			delete t;
			delete tld;
			rnum--;
		}
		/*
		 * If there are some threads still in work state,
		 * release it once finishe the work.
		 */
		//num = c;
		LASSERT(idle >= 0);
		if (idle == 0)
			poolState = pool_FullLoadState;
	} else { /* add the new threads into the pool */
		while (rnum < c) {
			t = new Thread;
			tld = new ThreadLocalData;
			memset(tld, 0, sizeof(*tld));
			tld->m = NULL;
			tld->p = this;
			tld->n = site;
			tld->t = t;
			tld->id = counter++;
			tld->flags = TLD_FROM_POOL;

			t->CreateThread(ProcessOneTask, tld);
			t->Insert(&idleQ);
			rnum++;
			idle++;
		}
		if (poolState == pool_FullLoadState && idle > 0 && check) {
			Signal();
			poolState = pool_RunState;
		}
		
	}

	return rnum;
}
开发者ID:yingjinqian,项目名称:Lustre-Simulator,代码行数:55,代码来源:processor.cpp

示例2: NextIdleThreadFromPool

Processor::~Processor()
{
	Thread *t;

	while ((t = NextIdleThreadFromPool()) != NULL) {
		ThreadLocalData *tld;

		tld = t->GetTLD();
		delete tld;
		delete t;
	}
}
开发者ID:yingjinqian,项目名称:Lustre-Simulator,代码行数:12,代码来源:processor.cpp

示例3: PoolStateMachine

void Processor::PoolStateMachine()
{
	switch (poolState) {
	case pool_RunState: {
		Message *msg;
		Thread *t;
		ThreadLocalData *tld; 

        /* I/O is throttled. */
        if (nrs->Throttling()) {
            poolState = pool_IdleState;
            return;
        }
		/* Initialize the working thread to handle
		 * various tasks and start it in the next tick. */
		msg = (Message *)nrs->Dequeue();
		if (msg == NULL) {
			poolState = pool_IdleState;
			return;
		}

        Print(NOW "Processor dequeues [email protected]%p, %d:%llu:%llu\n",
              Event::Clock(), &msg->io, msg->io.cmd, msg->io.off, msg->io.count);

		t = NextIdleThreadFromPool();
		assert(t != NULL);
		tld = t->GetTLD();
		tld->m = msg;

		tld->f = site->GetHandler();
		//t->Run();
		RunOneTask(t);

		/* Check for left queued tasks. */
		PoolStateMachine();
		break;
	}
	case pool_StartState:
		poolState = pool_IdleState;
	case pool_IdleState:
	case pool_FullLoadState:
		break;
	}
}
开发者ID:yingjinqian,项目名称:Lustre-Simulator,代码行数:44,代码来源:processor.cpp


注:本文中的Thread::GetTLD方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。