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); }
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; }