From e5723722d0d2c8f0a26368ab5207a3bd8d506762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D0=BE=D0=BC=D0=B5=D0=BD=D0=BA=D0=BE=20=D0=A1=D1=82?= =?UTF-8?q?=D0=B5=D0=BF=D0=B0=D0=BD=20=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B8=D1=87?= Date: Thu, 19 Mar 2020 14:54:53 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@961 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- src_main/concurrent/piblockingdequeue.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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; }