@brief Adds a value to back of the queue */
| 68 | |
| 69 | /** @brief Adds a value to back of the queue */ |
| 70 | void push(T value) |
| 71 | { |
| 72 | // Make the new data outside of the lock to minimize lock time |
| 73 | auto new_value = std::make_unique<T>(std::move(value)); |
| 74 | auto new_node = std::make_unique<_Node>(); |
| 75 | |
| 76 | // Adding to the queue only modifies the tail |
| 77 | { |
| 78 | std::lock_guard<std::mutex> lk(tail_mtx_); |
| 79 | tail_->data_ = std::move(new_value); |
| 80 | tail_->next_ = std::move(new_node); |
| 81 | tail_ = tail_->next_.get(); |
| 82 | } |
| 83 | // Update the condition variable (for wait_and_pop) |
| 84 | data_available_.notify_one(); |
| 85 | } |
| 86 | |
| 87 | void wake_all(bool stop = false) |
| 88 | { |
no test coverage detected