17 #include <condition_variable> 38 std::unique_lock<std::mutex> lock(queue_mutex_);
39 pop_cv_.wait(lock, [
this] {
return !this->q_.full(); });
40 q_.push_back(std::move(item));
42 push_cv_.notify_one();
49 std::unique_lock<std::mutex> lock(queue_mutex_);
50 q_.push_back(std::move(item));
52 push_cv_.notify_one();
57 bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration)
60 std::unique_lock<std::mutex> lock(queue_mutex_);
61 if (!push_cv_.wait_for(lock, wait_duration, [
this] { return !this->q_.empty(); }))
65 q_.pop_front(popped_item);
78 std::unique_lock<std::mutex> lock(queue_mutex_);
79 pop_cv_.wait(lock, [
this] {
return !this->q_.full(); });
80 q_.push_back(std::move(item));
81 push_cv_.notify_one();
87 std::unique_lock<std::mutex> lock(queue_mutex_);
88 q_.push_back(std::move(item));
89 push_cv_.notify_one();
94 bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration)
96 std::unique_lock<std::mutex> lock(queue_mutex_);
97 if (!push_cv_.wait_for(lock, wait_duration, [
this] { return !this->q_.empty(); }))
101 q_.pop_front(popped_item);
102 pop_cv_.notify_one();
110 std::unique_lock<std::mutex> lock(queue_mutex_);
111 return q_.overrun_counter();
115 std::mutex queue_mutex_;
116 std::condition_variable push_cv_;
117 std::condition_variable pop_cv_;
void enqueue_nowait(T &&item)
mpmc_blocking_queue(size_t max_items)
bool dequeue_for(T &popped_item, std::chrono::milliseconds wait_duration)