| 32 | } |
| 33 | |
| 34 | void worker_thread::wait() |
| 35 | { |
| 36 | std::unique_lock<std::mutex> lock(_mutex); |
| 37 | if(!_enqueued_operations.empty()) |
| 38 | { |
| 39 | // Before going to sleep, wake up the other thread to avoid deadlocks |
| 40 | _condition_wait.notify_all(); |
| 41 | // Wait until no operation is pending |
| 42 | _condition_wait.wait(lock, [this]{return _enqueued_operations.empty();}); |
| 43 | } |
| 44 | assert(_enqueued_operations.empty()); |
| 45 | } |
| 46 | |
| 47 | |
| 48 | void worker_thread::halt() |