From 015bb675d6eb177900c8ac94a6d35edc5ad90576 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Wed, 9 May 2018 00:11:35 +0200 Subject: 9.9 --- zen/thread.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'zen/thread.h') diff --git a/zen/thread.h b/zen/thread.h index bfb66c31..3721b3c7 100755 --- a/zen/thread.h +++ b/zen/thread.h @@ -37,12 +37,11 @@ public: template bool tryJoinFor(const std::chrono::duration& relTime) { - if (threadCompleted_.wait_for(relTime) == std::future_status::ready) - { - stdThread_.join(); //runs thread-local destructors => this better be fast!!! - return true; - } - return false; + if (threadCompleted_.wait_for(relTime) != std::future_status::ready) + return false; + + stdThread_.join(); //runs thread-local destructors => this better be fast!!! + return true; } private: @@ -297,7 +296,7 @@ public: setConditionVar(&cv); ZEN_ON_SCOPE_EXIT(setConditionVar(nullptr)); - //"interrupted" is not protected by cv's mutex => signal may get lost!!! => add artifical time out to mitigate! CPU: 0.25% vs 0% for longer time out! + //"interrupted_" is not protected by cv's mutex => signal may get lost!!! => add artifical time out to mitigate! CPU: 0.25% vs 0% for longer time out! while (!cv.wait_for(lock, std::chrono::milliseconds(1), [&] { return this->interrupted_ || pred(); })) ; -- cgit