BDE 4.14.0 Production release
|
#include <bslmt_sluice.h>
Public Types | |
enum | { e_TIMED_OUT = TimedSemaphore::e_TIMED_OUT } |
The value timedWait returns when a timeout occurs. More... | |
Public Member Functions | |
Sluice (bslma::Allocator *basicAllocator=0) | |
Sluice (bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0) | |
Sluice (const bsl::chrono::system_clock &, bslma::Allocator *basicAllocator=0) | |
Sluice (const bsl::chrono::steady_clock &, bslma::Allocator *basicAllocator=0) | |
~Sluice () | |
Destroy this sluice. | |
const void * | enter () |
void | signalAll () |
void | signalOne () |
int | timedWait (const void *token, const bsls::TimeInterval &absTime) |
template<class CLOCK , class DURATION > | |
int | timedWait (const void *token, const bsl::chrono::time_point< CLOCK, DURATION > &absTime) |
void | wait (const void *token) |
bsls::SystemClockType::Enum | clockType () const |
Return the clock type used for timeouts. | |
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
|
explicit |
|
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 |
Create a sluice. Use the realtime system clock as the clock against which the absTime
timeouts passed to the timedWait
methods are interpreted (see {Supported Clock-Types} in the component-level documentation). Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used.
|
explicit |
Create a sluice. Use the monotonic system clock as the clock against which the absTime
timeouts passed to the timedWait
methods are interpreted (see {Supported Clock-Types} in the component-level documentation). Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used.
bslmt::Sluice::~Sluice | ( | ) |
|
inline |
const void * bslmt::Sluice::enter | ( | ) |
Enter this sluice, and return the token on which the calling thread must subsequently wait. The behavior is undefined unless 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 bsl::chrono::time_point< CLOCK, DURATION > & | 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 associated with the time point. 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. The behavior is undefined unless token
was obtained from a call to enter
by this thread, and was not subsequently released (via a call to timedWait
or wait
).
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. The behavior is undefined unless 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
. The behavior is undefined unless token
was obtained from a call to enter
by this thread, and was not subsequently released (via a call to timedWait
or wait
).