opensurgsim
Public Member Functions | List of all members
SurgSim::Framework::Barrier Class Reference

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

Detailed Description

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.

Constructor & Destructor Documentation

§ Barrier()

SurgSim::Framework::Barrier::Barrier ( size_t  count)
explicit

Construct the barrier.

Parameters
countNumber of threads to synchronize, can't be 0.

Member Function Documentation

§ wait()

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.

Parameters
successa value indicating if this thread has been successful, used to determine the return value across all threads.
Returns
true if all threads claimed success, false otherwise.

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