void sprawl::threading::ThreadManager::eventLoop_(ThreadData* threadData) { collections::ConcurrentQueue<TaskInfo*>& queue = m_flagGroups.Get(threadData->flags)->taskQueue; Event& mailbox = threadData->mailbox; while(m_running) { TaskInfo* task; while(queue.Dequeue(task)) { bool expected = false; if(task->taken.compare_exchange_strong(expected, true)) { task->what(); delete task; } } if(m_syncState == SyncState::Threads) { ++m_syncCount; m_workerSyncEvent.Notify(); while(m_syncState == SyncState::Threads) { mailbox.Wait(); } ++m_syncCount; m_workerSyncEvent.Notify(); } else { mailbox.Wait(); } } }
void sprawl::threading::ThreadManager::pump_() { TaskInfo* task; while(m_mainThreadQueue->Dequeue(task)) { bool expected = false; if(task->taken.compare_exchange_strong(expected, true)) { task->what(); delete task; } } }