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;