|
BDE 4.14.0 Production release
|
Provide a "sluice" class.
This component provides a "sluice" class, bslmt::Sluice. A sluice is useful for controlling the release of threads from a common synchronization point. One or more threads may "enter" a bslmt::Sluice object (via the enter method), and then wait to be released (via either the wait or timedWait method). Either one waiting thread (via the signalOne method), or all waiting threads (via the signalAll method), may be signaled for release. In either case, bslmt::Sluice provides a guarantee against starvation; newly-entering threads will not indefinitely prevent threads that previously entered from being signaled.
bsls::SystemClockType supplies the enumeration indicating the system clock on which timeouts supplied to other methods should be based. If the clock type indicated at construction is bsls::SystemClockType::e_REALTIME, the absTime argument passed to the timedWait method should be expressed as an absolute offset since 00:00:00 UTC, January 1, 1970 (which matches the epoch used in bsls::SystemTime::now(bsls::SystemClockType::e_REALTIME). If the clock type indicated at construction is bsls::SystemClockType::e_MONOTONIC, the absTime argument passed to the timedWait method should be expressed as an absolute offset since the epoch of this clock (which matches the epoch used in bsls::SystemTime::now(bsls::SystemClockType::e_MONOTONIC).
This section illustrates intended use of this component.
bslmt::Sluice is intended to be used to implement other synchronization mechanisms. In particular, the functionality provided by bslmt::Sluice is useful for implementing a condition variable: