| 83 | |
| 84 | // Add an element to the queue. |
| 85 | template <void (std::deque<T>::*Push)(T &&)> void push(T &&t, bool priority) { |
| 86 | std::lock_guard<std::mutex> lock(mutex_); |
| 87 | if (priority) |
| 88 | (priority_.*Push)(std::move(t)); |
| 89 | else |
| 90 | (queue_.*Push)(std::move(t)); |
| 91 | ++total_count_; |
| 92 | waiter_->cv.notify_one(); |
| 93 | } |
| 94 | |
| 95 | void pushBack(T &&t, bool priority = false) { push<&std::deque<T>::push_back>(std::move(t), priority); } |
| 96 |