From: Arnaud Giersch Date: Wed, 18 Nov 2020 12:00:11 +0000 (+0100) Subject: Please Sonar (even if there was no bug). X-Git-Tag: v3.26~189 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/1ca536fcc55000e05c1a8e79f9eb820a76004974 Please Sonar (even if there was no bug). --- diff --git a/src/include/xbt/parmap.hpp b/src/include/xbt/parmap.hpp index ac909e78dd..bc3b9f6e78 100644 --- a/src/include/xbt/parmap.hpp +++ b/src/include/xbt/parmap.hpp @@ -322,10 +322,8 @@ template void Parmap::PosixSynchro::master_signal() template void Parmap::PosixSynchro::master_wait() { std::unique_lock lk(done_mutex); - while (this->parmap.thread_counter < this->parmap.num_workers) { - /* wait for all workers to be ready */ - done_cond.wait(lk); - } + /* wait for all workers to be ready */ + done_cond.wait(lk, [this]() { return this->parmap.thread_counter >= this->parmap.num_workers; }); } template void Parmap::PosixSynchro::worker_signal() @@ -342,9 +340,7 @@ template void Parmap::PosixSynchro::worker_wait(unsigned round) { std::unique_lock lk(ready_mutex); /* wait for more work */ - while (this->parmap.work_round != round) { - ready_cond.wait(lk); - } + ready_cond.wait(lk, [this, round]() { return this->parmap.work_round == round; }); } #if HAVE_FUTEX_H