#include <bslmt_timedsemaphore.h>
This class implements a portable timed semaphore type for thread synchronization. It forwards all requests to an appropriate platform-specific implementation.
See bslmt_timedsemaphore
◆ anonymous enum
The value timedWait returns when a timeout occurs.
◆ TimedSemaphore() [1/2]
Create a timed semaphore initially having a count of 0. Optionally specify a clockType indicating the type of the system clock against which the absTime timeouts passed to the timedWait methods are to be interpreted (see {Supported Clock-Types} in the component-level documentation). If clockType is not specified then the realtime system clock is used. This method does not return normally unless there are sufficient system resources to construct the object.
◆ TimedSemaphore() [2/2]
Create a timed semaphore initially having the specified count. Optionally specify a clockType indicating the type of the system clock against which the absTime timeouts passed to the timedWait methods are to be interpreted (see {Supported Clock-Types} in the component-level documentation). If clockType is not specified then the realtime system clock is used. This method does not return normally unless there are sufficient system resources to construct the object.
- Precondition
- The behavior is undefined unless
0 <= count.
◆ ~TimedSemaphore()
| bslmt::TimedSemaphore::~TimedSemaphore |
( |
| ) |
|
|
inline |
Destroy this timed semaphore.
◆ clockType()
Return the clock type used for timeouts.
◆ post() [1/2]
| void bslmt::TimedSemaphore::post |
( |
| ) |
|
|
inline |
Atomically increment the count of this timed semaphore.
◆ post() [2/2]
| void bslmt::TimedSemaphore::post |
( |
int |
value | ) |
|
|
inline |
Atomically increase the count of this timed semaphore by the specified value.
- Precondition
- The behavior is undefined unless
value > 0.
◆ timedWait()
Block until the count of this semaphore is a positive value, 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). If the absTime timeout did not expire before the count attained a positive value, atomically decrement the count and return 0. If the absTime timeout did expire, return e_TIMED_OUT with no effect on the count. Any other value indicates that an error has occurred. Errors are unrecoverable. After an error, the semaphore may be destroyed, but any other use has undefined behavior. On Windows platforms, this method may return e_TIMED_OUT slightly before absTime.
◆ tryWait()
| int bslmt::TimedSemaphore::tryWait |
( |
| ) |
|
|
inline |
If the count of this timed semaphore is positive, atomically decrement the count and return 0; otherwise, return a non-zero value with no effect on the count.
◆ wait()
| void bslmt::TimedSemaphore::wait |
( |
| ) |
|
|
inline |
Block until the count of this timed semaphore is a positive value, then atomically decrement the count and return.
The documentation for this class was generated from the following file: