|
|
|
@ -133,7 +133,14 @@ class multiqueue_handler
|
|
|
|
|
bool push_(T* o, bool blocking) noexcept
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<std::mutex> lock(q_mutex);
|
|
|
|
|
while (active_ and blocking and buffer.full()) {
|
|
|
|
|
if (not blocking) {
|
|
|
|
|
// non-blocking case
|
|
|
|
|
if (not active_ or buffer.full()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// blocking case
|
|
|
|
|
while (active_ and buffer.full()) {
|
|
|
|
|
nof_waiting++;
|
|
|
|
|
cv_full.wait(lock);
|
|
|
|
|
nof_waiting--;
|
|
|
|
@ -143,6 +150,7 @@ class multiqueue_handler
|
|
|
|
|
cv_exit.notify_one();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
buffer.push(std::forward<T>(*o));
|
|
|
|
|
if (consumer_notify_needed) {
|
|
|
|
|
// Note: The consumer thread only needs to be notified and awaken when queues transition from empty to non-empty
|
|
|
|
|