Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
Barrier with changeable threshold. More...
#include <FXBarrier.h>
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. More... | |
FXuint | threshold () const |
Return the threshold, i.e. More... | |
FXbool | wait () |
Wait for all threads to hit the barrier. More... | |
FXbool | release () |
Release all waiting threads unconditionally; all waiting threads will break through the barrier and proceed, even if the threshold was not exceeded. More... | |
~FXBarrier () | |
Delete the barrier. | |
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.
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.
|
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.
Copyright © 1997-2022 Jeroen van der Zijp |