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