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:
parent
3ec30bf537
commit
c1b523d642
1 changed files with 14 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue