Base Framework
Public Member Functions | Protected Types | Protected Attributes | List of all members
Barrier Class Reference

Barrier synchronization object. More...

#include <base/concurrency/Barrier.h>

Inherits Object.

Public Member Functions

 Barrier ()
 
unsigned int getCount () const
 
void setCount (unsigned int value)
 
unsigned int getWaiting () const
 
unsigned int wait (bool reset=false)
 
void reset ()
 
 ~Barrier ()
 

Protected Types

typedef SpinLock Guard
 

Protected Attributes

Guard guard
 
Event event
 
Event resetEvent
 
MutualExclusion mutex
 
unsigned int count = 0
 
unsigned int waiting = 0
 

Detailed Description

Barrier synchronization object.

Implementation of a barrier.

See also
Event MutualExclusion Semaphore
Version
1.0

Constructor & Destructor Documentation

◆ Barrier()

Barrier::Barrier ( )

Initializes the barrier with a count of 0. Raises ResourceException if unable to allocate the required resources.

◆ ~Barrier()

Barrier::~Barrier ( )

Destroys the barrier.

Member Function Documentation

◆ getCount()

unsigned int Barrier::getCount ( ) const

Returns the barrier count.

◆ getWaiting()

unsigned int Barrier::getWaiting ( ) const

Returns the number of waiting threads.

◆ reset()

void Barrier::reset ( )

Resets the barrier. This method is used to wake up all waiting threads before the barrier count has been reached.

◆ setCount()

void Barrier::setCount ( unsigned int  value)

Sets the barrier count.

◆ wait()

unsigned int Barrier::wait ( bool  reset = false)

The executing thread blocks until the barrier has been reached (i.e. the number of waiting threads equals the barrier count).

Parameters
resetSpecifies whether or not to reset.
Returns
The number of still waiting threads.

Member Data Documentation

◆ count

unsigned int Barrier::count = 0
protected

The barrier count.

◆ event

Event Barrier::event
protected

◆ guard

Guard Barrier::guard
protected

Guard.

◆ mutex

MutualExclusion Barrier::mutex
protected

Mutual exclusion.

◆ resetEvent

Event Barrier::resetEvent
protected

Reset event.

◆ waiting

unsigned int Barrier::waiting = 0
protected

The number of waiting threads.