예제 #1
0
void WorkerThread::DoTasks() {
	
	ThreadTask* task = 0;

	do
	{
		//Process any tasks in our queue
		while (task = PopTask())
		{
			task->Run();
			delete task;
		}

		//We ran out of tasks, so try to see if we can steal one
		task = StealTask();
		if (task) {
			task->Run();
			delete task;
		}

	} while (task);	
}
예제 #2
0
파일: Thread.cpp 프로젝트: neodyme60/Xli
    void Thread::thread_func(void* arg)
    {
        Thread* thread = (Thread*)arg;
        ThreadTask* task = thread->_task;
        
        task->_stopRequested = false;
        SetCurrentThreadName(task->ToString());

        try
        {
            task->Run();
        }
        catch (const Exception& e)
        {
            CoreLib::OnUnhandledException(e, task->ToString());
        }
        catch (...)
        {
            Xli::Exception e("An unsupported C++ exception was thrown");
            CoreLib::OnUnhandledException(e, task->ToString());
        }

        thread->_state = ThreadStateStopped;
    }