| 58 | } |
| 59 | |
| 60 | bool worker_thread_executor::drain_queue() { |
| 61 | std::unique_lock<std::mutex> lock(m_lock); |
| 62 | wait_for_task(lock); |
| 63 | |
| 64 | assert(lock.owns_lock()); |
| 65 | assert(!m_public_queue.empty() || m_abort); |
| 66 | |
| 67 | if (m_abort) { |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | assert(m_private_queue.empty()); |
| 72 | std::swap(m_private_queue, m_public_queue); // reuse underlying allocations. |
| 73 | lock.unlock(); |
| 74 | |
| 75 | return drain_queue_impl(); |
| 76 | } |
| 77 | |
| 78 | void worker_thread_executor::work_loop() { |
| 79 | details::s_tl_this_worker = this; |