diff --git a/src_main/concurrent/piblockingdequeue.h b/src_main/concurrent/piblockingdequeue.h index d7ed9f98..fb480f9a 100644 --- a/src_main/concurrent/piblockingdequeue.h +++ b/src_main/concurrent/piblockingdequeue.h @@ -119,13 +119,14 @@ public: * @param defaultVal value, which returns if the specified waiting time elapses before an element is available * @return the head of this queue, or defaultVal if the specified waiting time elapses before an element is available */ - T poll(int timeoutMs, const T & defaultVal) { + T poll(int timeoutMs, const T & defaultVal, bool* isOk = nullptr) { T t; mutex.lock(); - bool isOk = cond_var_add->waitFor(mutex, timeoutMs, [&]() { return !PIDeque::isEmpty(); }); - t = isOk ? T(PIDeque::take_front()) : defaultVal; + bool isNotEmpty = cond_var_add->waitFor(mutex, timeoutMs, [&]() { return !PIDeque::isEmpty(); }); + t = isNotEmpty ? T(PIDeque::take_front()) : defaultVal; mutex.unlock(); - if (isOk) cond_var_rem->notifyOne(); + if (isNotEmpty) cond_var_rem->notifyOne(); + if (isOk != nullptr) *isOk = isNotEmpty; return t; }