#include <Barrier.h>
Inheritance diagram for ZThread::Barrier< Count, LockType >:
Public Member Functions | |
Barrier () | |
Create a Barrier. | |
Barrier (const Task &task) | |
virtual | ~Barrier () |
Destroy this Barrier. | |
virtual void | wait () |
virtual bool | wait (unsigned long timeout) |
void | shatter () |
void | reset () |
An optional Runnable command may be associated with the Barrier. This will be run() when the Nth thread arrives and Barrier is not broken.
Error Checking
A Barrier uses an all-or-nothing. All threads involved must successfully meet at Barrier. If any one of those threads leaves before all the threads have (as the result of an error or exception) then all threads present at the Barrier will throw BrokenBarrier_Exception.
A broken Barrier will cause all threads attempting to wait() on it to throw a BrokenBarrier_Exception.
A Barrier will remain 'broken', until it is manually reset().
ZThread::Barrier< Count, LockType >::Barrier | ( | const Task & | task | ) | [inline] |
void ZThread::Barrier< Count, LockType >::reset | ( | ) | [inline] |
void ZThread::Barrier< Count, LockType >::shatter | ( | ) | [inline] |
Break the Barrier ending the wait for any threads that were waiting on the barrier.
virtual bool ZThread::Barrier< Count, LockType >::wait | ( | unsigned long | timeout | ) | [inline, virtual] |
Enter barrier and wait for the other threads to arrive. This can block up to the amount of time specified with the timeout parameter. The barrier will not break if a thread leaves this function due to a timeout.
timeout | maximum amount of time, in milliseconds, to wait before |
BrokenBarrier_Exception | thrown when any thread has left a wait on this Barrier as a result of an error. | |
Interrupted_Exception | thrown when the calling thread is interrupted. A thread may be interrupted at any time, prematurely ending a wait for one thread and breaking the barrier for all threads |
If an exception was thrown, the barrier is broken
Implements ZThread::Waitable.
virtual void ZThread::Barrier< Count, LockType >::wait | ( | ) | [inline, virtual] |
Enter barrier and wait for the other threads to arrive. This can block for an indefinite amount of time.
BrokenBarrier_Exception | thrown when any thread has left a wait on this Barrier as a result of an error. | |
Interrupted_Exception | thrown when the calling thread is interrupted. A thread may be interrupted at any time, prematurely ending a wait for one thread and breaking the barrier for all threads |
If an exception was thrown, the barrier is broken
Implements ZThread::Waitable.