piranha  0.10
Public Member Functions | List of all members
piranha::thread_barrier Class Reference

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...
 

Detailed Description

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.

See also
http://www.boost.org/doc/libs/release/doc/html/thread/synchronization.html

Definition at line 64 of file thread_barrier.hpp.

Constructor & Destructor Documentation

◆ thread_barrier()

piranha::thread_barrier::thread_barrier ( unsigned  count)
inlineexplicit

Constructor.

Construct a barrier for count threads.

Parameters
countnumber of threads for which the barrier is configured.
Exceptions
std::invalid_argumentif count == 0.
std::system_errorin case of failure(s) by threading primitives.

Definition at line 76 of file thread_barrier.hpp.

◆ ~thread_barrier()

piranha::thread_barrier::~thread_barrier ( )
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.

Member Function Documentation

◆ wait()

bool piranha::thread_barrier::wait ( )
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.

Returns
true for exactly one thread from each batch of waiting threads, false otherwise.

Definition at line 116 of file thread_barrier.hpp.


The documentation for this class was generated from the following file: