From 53efc802f7ba4906a74f32a244442a9eb31af56f Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Fri, 24 Jun 2016 16:31:59 +0200 Subject: [PATCH] [s4u] Restore the barrier as it was --- examples/s4u/actions-comm/s4u_actions-comm.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/s4u/actions-comm/s4u_actions-comm.cpp b/examples/s4u/actions-comm/s4u_actions-comm.cpp index 35f4ecf3cc..826d6c97ca 100644 --- a/examples/s4u/actions-comm/s4u_actions-comm.cpp +++ b/examples/s4u/actions-comm/s4u_actions-comm.cpp @@ -173,13 +173,15 @@ static void action_barrier(const char *const *action) } ACT_DEBUG("Entering barrier: %s (%d already there)", NAME, processes_arrived_sofar); - std::unique_lock lock(*mutex); - if (++processes_arrived_sofar == communicator_size) { - // We can notify without the lock: - lock.unlock(); - cond->notify_all(); - } else { - cond->wait(lock); + { + std::unique_lock lock(*mutex); + if (++processes_arrived_sofar == communicator_size) { + // We can notify without the lock: + lock.unlock(); + cond->notify_all(); + } else { + cond->wait(lock); + } } ACT_DEBUG("Exiting barrier: %s", NAME); -- 2.20.1