feat(util/worker_queue): allow main thread to process tasks while waiting

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-07-25 23:24:04 -07:00
parent 3ec30bf537
commit c1b523d642

View file

@ -101,9 +101,20 @@ public:
}
m_todo.clear();
} else {
m_todo_cv.notify_all();
for (thread_ptr & t : m_threads)
t->join();
try {
while (auto t = next_task()) {
add_result((*t)());
}
m_todo_cv.notify_all();
for (thread_ptr & t : m_threads)
t->join();
} catch (...) {
for (auto & th : m_threads)
th->request_interrupt();
for (auto & th : m_threads)
th->join();
throw;
}
if (m_failed_thread >= 0)
m_thread_exceptions[m_failed_thread]->rethrow();
if (m_interrupted)