Return false when the queue is full.
| 17 | |
| 18 | // Return false when the queue is full. |
| 19 | bool push(T t) { |
| 20 | { |
| 21 | std::lock_guard<std::mutex> lock(mutex_); |
| 22 | if (queue_.size() >= max_size_) { |
| 23 | return false; |
| 24 | } |
| 25 | queue_.push(std::move(t)); |
| 26 | } |
| 27 | cv_.notify_one(); |
| 28 | return true; |
| 29 | } |
| 30 | |
| 31 | // blocking pop with timeout |
| 32 | std::optional<T> pop(int timeout_ms) { |
no test coverage detected