// virtual
void LLQueuedThread::run()
{
	// call checPause() immediately so we don't try to do anything before the class is fully constructed
	checkPause();
	startThread();
	mStarted = TRUE;
	
	while (1)
	{
		// this will block on the condition until runCondition() returns true, the thread is unpaused, or the thread leaves the RUNNING state.
		checkPause();
		
		if (isQuitting())
		{
			endThread();
			break;
		}

		mIdleThread = FALSE;

		threadedUpdate();
		
		int res = processNextRequest();
		if (res == 0)
		{
			mIdleThread = TRUE;
			ms_sleep(1);
		}
		//LLThread::yield(); // thread should yield after each request		
	}
	LL_INFOS() << "LLQueuedThread " << mName << " EXITING." << LL_ENDL;
}
Ejemplo n.º 2
0
void ofxPixelPusherUnit::threadedFunction() {
    while (isThreadRunning()) {
        if (lock()) {
            threadedUpdate();
            unlock();
            sleep(sleepTime);
        }
    }
}