| 323 | |
| 324 | template <typename T> |
| 325 | bool ThreadsafeQueue<T>::popBlocking(T& value) { |
| 326 | std::unique_lock<std::mutex> lk(mutex_); |
| 327 | // Wait until there is data in the queue or shutdown requested. |
| 328 | data_cond_.wait(lk, [this] { return !data_queue_.empty() || shutdown_; }); |
| 329 | // Return false in case shutdown is requested. |
| 330 | if (shutdown_) return false; |
| 331 | value = std::move(*data_queue_.front()); |
| 332 | data_queue_.pop(); |
| 333 | lk.unlock(); // Unlock before notify. |
| 334 | data_cond_.notify_one(); |
| 335 | return true; |
| 336 | } |
| 337 | |
| 338 | template <typename T> |
| 339 | std::shared_ptr<T> ThreadsafeQueue<T>::popBlocking() { |