| 40 | } |
| 41 | |
| 42 | void worker_thread_executor::wait_for_task(std::unique_lock<std::mutex>& lock) { |
| 43 | assert(lock.owns_lock()); |
| 44 | if (!m_public_queue.empty() || m_abort) { |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | while (true) { |
| 49 | lock.unlock(); |
| 50 | |
| 51 | m_semaphore.acquire(); |
| 52 | |
| 53 | lock.lock(); |
| 54 | if (!m_public_queue.empty() || m_abort) { |
| 55 | break; |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | bool worker_thread_executor::drain_queue() { |
| 61 | std::unique_lock<std::mutex> lock(m_lock); |