|
BDE 4.39.x Production Release
|
#include <bslmt_sluice.h>
This class controls the release of threads from a common synchronization point. One or more threads may "enter" a Sluice object, and then wait to be released. Either one waiting thread (via the signalOne method), or all waiting threads (via the signalAll method), may be signaled for release. In any case, Sluice provides a guarantee against starvation.
See bslmt_sluice
Public Types | |
| enum | { e_TIMED_OUT = TimedSemaphore::e_TIMED_OUT } |
Public Member Functions | |
| Sluice (bslma::Allocator *basicAllocator=0) | |
| Sluice (bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0) | |
| ~Sluice () | |
| const void * | enter () |
| void | signalAll () |
| void | signalOne () |
| int | timedWait (const void *token, const bsls::TimeInterval &absTime) |
| void | wait (const void *token) |
| bsls::SystemClockType::Enum | clockType () const |
|
explicit |
Create a sluice. Optionally specify a clockType indicating the type of the system clock against which the bsls::TimeInterval absTime timeouts passed to the timedWait method are to be interpreted (see {Supported Clock-Types} in the component documentation). If clockType is not specified then the realtime system clock is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.
|
explicit |
| bslmt::Sluice::~Sluice | ( | ) |
Destroy this sluice.
|
inline |
Return the clock type used for timeouts.
| const void * bslmt::Sluice::enter | ( | ) |
Enter this sluice, and return the token on which the calling thread must subsequently wait.
wait or timedWait is invoked with the token before this sluice is destroyed. | void bslmt::Sluice::signalAll | ( | ) |
Signal all threads that have entered this sluice and have not yet been released.
| void bslmt::Sluice::signalOne | ( | ) |
Signal one thread that has entered this sluice and has not yet been released.
| int bslmt::Sluice::timedWait | ( | const void * | token, |
| const bsls::TimeInterval & | absTime | ||
| ) |
Wait for the specified token to be signaled, or until the specified absTime timeout expires. absTime is an absolute time represented as an interval from some epoch, which is determined by the clock indicated at construction (see {Supported Clock-Types} in the component-level documentation). Return 0 on success, and e_TIMED_OUT on timeout. Any other value indicates that an error has occurred. Errors are unrecoverable. After an error, the sluice may be destroyed, but any other use has undefined behavior. The token is released whether or not a timeout occurred.
token was obtained from a call to enter by this thread, and was not subsequently released (via a call to timedWait or wait). | void bslmt::Sluice::wait | ( | const void * | token | ) |
Wait for the specified token to be signaled, and release the token.
token was obtained from a call to enter by this thread, and was not subsequently released (via a call to timedWait or wait).