From d7caa3043d8db43f8dbe8a96c980d766d764273f Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Tue, 1 Apr 2014 11:32:46 -0500 Subject: [PATCH] Fixing counting_semaphore::signal --- hpx/lcos/local/counting_semaphore.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hpx/lcos/local/counting_semaphore.hpp b/hpx/lcos/local/counting_semaphore.hpp index 835503362533..be0ec08d6d3c 100644 --- a/hpx/lcos/local/counting_semaphore.hpp +++ b/hpx/lcos/local/counting_semaphore.hpp @@ -125,8 +125,9 @@ namespace hpx { namespace lcos { namespace local template void signal_locked(boost::int64_t count, Lock& l) { + // release no more threads than we get resources value_ += count; - while (value_ >= 0) + for (boost::int64_t i = 0; value_ >= 0 && i < count; ++i) { if (!cond_.notify_one(l)) break;