Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FX::FXBarrier Class Reference

Barrier with changeable threshold. More...

#include <FXBarrier.h>

List of all members.

Public Member Functions

 FXBarrier (FXuint thr=1)
 Initialize the barrier with initial threshold thr.
FXbool threshold (FXuint thr)
 Change threshold to thr, possibly releasing all waiting threads.
FXuint threshold () const
 Return the threshold, i.e.
FXbool wait ()
 Wait for all threads to hit the barrier.
FXbool release ()
 Release all waiting threads unconditionally; all waiting threads will break through the barrier and proceed, even if the threshold was not exceeded.
 ~FXBarrier ()
 Delete the barrier.

Detailed Description

Barrier with changeable threshold.

A Barrier holds back threads arriving at the barrier, until the number of threads exceeds some threshold (quorum), after which all threads can progress. The Barrier can be broken in two additional ways. First, the threshold value could be changed to a number lower than the currently waiting number of threads. Second, the waiting threads could be released unconditionally, without reaching quorum. Since there must be at least one thread, the theshold value should be at least 1. Deleting the barrier while threads are blocked in not allowed.


Member Function Documentation

FXbool FX::FXBarrier::release ( )

Release all waiting threads unconditionally; all waiting threads will break through the barrier and proceed, even if the threshold was not exceeded.

Return true if any threads were waiting.

FXbool FX::FXBarrier::threshold ( FXuint  thr)

Change threshold to thr, possibly releasing all waiting threads.

Return true if current count now exceeds the threshold.

FXuint FX::FXBarrier::threshold ( ) const
inline

Return the threshold, i.e.

number at which the barrier breaks through.

FXbool FX::FXBarrier::wait ( )

Wait for all threads to hit the barrier.

Returns true for one thread, false for all other threads.


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

Copyright © 1997-2016 Jeroen van der Zijp