void* WorkThread::threadStartFunc(void *inData)
{
   // Called from newly created pthread, starts the run loop of our thread
   
   WorkThread* thread = static_cast<WorkThread*>(inData);
   thread->run();
}
示例#2
0
void PoolThread::run() {

	for(;;) {

		WakeUpType wakeUpType = sleep(40000); // 40 sec of timeout
		
		for(;;) {
			WorkThread* pWork;
			{
				ScopedLock<FastMutex> lock(_mutex);
				if(_jobs.empty()) {
					if(wakeUpType!=WAKEUP) { // STOP or TIMEOUT
						if(wakeUpType==TIMEOUT)
							stop();
						return;
					}
					break;
				}
				pWork = _jobs.front();
			}

			setPriority(pWork->priority);
			pWork->run();
			
			{
				ScopedLock<FastMutex> lock(_mutex);
				_jobs.pop_front();
			}
			--_queue;
		}
	}
}