piranha
0.10
|
Thread barrier. More...
#include <piranha/thread_barrier.hpp>
Public Member Functions | |
thread_barrier (unsigned count) | |
Constructor. More... | |
thread_barrier (const thread_barrier &)=delete | |
Deleted copy constructor. | |
thread_barrier (thread_barrier &&)=delete | |
Deleted move constructor. | |
~thread_barrier () | |
Destructor. More... | |
bool | wait () |
Wait method. More... | |
Thread barrier.
Also known as a rendezvous, a barrier is a synchronization point between multiple threads. The barrier is configured for a particular number of threads n
, and as threads reach the barrier they must wait until all n
threads have arrived. Once the n
-th thread has reached the barrier, all the waiting threads can proceed, and the barrier is reset.
This class has been minimally adapted from the barrier class available from the Boost libraries.
Definition at line 64 of file thread_barrier.hpp.
|
inlineexplicit |
Constructor.
Construct a barrier for count
threads.
count | number of threads for which the barrier is configured. |
std::invalid_argument | if count == 0 . |
std::system_error | in case of failure(s) by threading primitives. |
Definition at line 76 of file thread_barrier.hpp.
|
inline |
Destructor.
No threads must be waiting on this when the destructor is called, otherwise the program will abort.
Definition at line 96 of file thread_barrier.hpp.
|
inline |
Wait method.
Block until count
threads have called wait() on this. When the count
-th thread calls wait(), all waiting threads are unblocked, and the barrier is reset.
true
for exactly one thread from each batch of waiting threads, false
otherwise. Definition at line 116 of file thread_barrier.hpp.