| 1574 | } |
| 1575 | |
| 1576 | void job_pool::wait_for_all() |
| 1577 | { |
| 1578 | std::unique_lock<std::mutex> lock(m_mutex); |
| 1579 | |
| 1580 | // Drain the job queue on the calling thread. |
| 1581 | while (!m_queue.empty()) |
| 1582 | { |
| 1583 | std::function<void()> job(m_queue.back()); |
| 1584 | m_queue.pop_back(); |
| 1585 | |
| 1586 | lock.unlock(); |
| 1587 | |
| 1588 | job(); |
| 1589 | |
| 1590 | lock.lock(); |
| 1591 | } |
| 1592 | |
| 1593 | // The queue is empty, now wait for all active jobs to finish up. |
| 1594 | m_no_more_jobs.wait(lock, [this]{ return !m_num_active_jobs; } ); |
| 1595 | } |
| 1596 | |
| 1597 | void job_pool::job_thread(uint32_t index) |
| 1598 | { |
no test coverage detected