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

## Barrier()

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

explicit

Construct the barrier.

Parameters

  count | Number 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

  success | a 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

## m_cond

boost::condition_variable SurgSim::Framework::Barrier::m_cond

private

## m_count

size_t SurgSim::Framework::Barrier::m_count

private

## m_generation

size_t SurgSim::Framework::Barrier::m_generation

private

## m_mutex

boost::mutex SurgSim::Framework::Barrier::m_mutex

private

## m_success

bool SurgSim::Framework::Barrier::m_success

private

## m_successResult

bool SurgSim::Framework::Barrier::m_successResult

private

## m_threshold

size_t SurgSim::Framework::Barrier::m_threshold

private

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

- SurgSim/Framework/Barrier.h
- SurgSim/Framework/Barrier.cpp