All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | 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 <SurgSim/Framework/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...
 

Private Attributes

boost::mutex m_mutex
 
boost::condition_variable m_cond
 
size_t m_threshold
 
size_t m_count
 
size_t m_generation
 
bool m_success
 
bool m_successResult
 

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

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

Construct the barrier.

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

Member Function Documentation

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.

Member Data Documentation

boost::condition_variable SurgSim::Framework::Barrier::m_cond
private
size_t SurgSim::Framework::Barrier::m_count
private
size_t SurgSim::Framework::Barrier::m_generation
private
boost::mutex SurgSim::Framework::Barrier::m_mutex
private
bool SurgSim::Framework::Barrier::m_success
private
bool SurgSim::Framework::Barrier::m_successResult
private
size_t SurgSim::Framework::Barrier::m_threshold
private

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