opensurgsim
|
Barrier class, synchronize a set of threads to wait at a common point, all threads will wait at Barrier::wait(val) until the number of threads calling wait is equal to the number given in the constructor. More...
#include <Barrier.h>
Public Member Functions | |
Barrier (size_t count) | |
Construct the barrier. More... | |
bool | wait (bool success) |
Waits until all count threads have called wait. More... | |
Barrier class, synchronize a set of threads to wait at a common point, all threads will wait at Barrier::wait(val) until the number of threads calling wait is equal to the number given in the constructor.
Additionally wait will return a boolean AND over all the values passed into the wait function, this can be used to signal a failure condition across threads.
|
explicit |
Construct the barrier.
count | Number of threads to synchronize, can't be 0. |
bool SurgSim::Framework::Barrier::wait | ( | bool | success | ) |
Waits until all count threads have called wait.
The wait calls in all of the threads waiting on a barrier will return the same value. This return value will be true if the success
argument was true in all of the threads; if any thread passes false, the return value will be false.
success | a value indicating if this thread has been successful, used to determine the return value across all threads. |