| 137 | } |
| 138 | |
| 139 | bool pop(T& t) |
| 140 | { |
| 141 | std::unique_lock<std::mutex> lock(impl_->mutex_); |
| 142 | while (impl_->queue_.empty() && !impl_->stop_) |
| 143 | impl_->condition_.wait(lock); |
| 144 | if (!impl_->queue_.empty()) |
| 145 | { |
| 146 | t = impl_->queue_.front(); |
| 147 | impl_->queue_.pop(); |
| 148 | return true; |
| 149 | } |
| 150 | return false; |
| 151 | } |
| 152 | |
| 153 | private: |
| 154 | std::shared_ptr<queue_impl<T>> impl_; |