#include <bslmt_fastpostsemaphoreimpl.h>
List of all members.
Detailed Description
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
class bslmt::FastPostSemaphoreImpl< ATOMIC_OP, MUTEX, CONDITION, THREADUTIL >
This class implements a semaphore type, optimized for post
, for thread synchronization.
See Component bslmt_fastpostsemaphoreimpl
Member Enumeration Documentation
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
- Enumerator:
e_SUCCESS |
indicates success
|
e_DISABLED |
indicates semaphore is disabled
|
e_TIMED_OUT |
indicates operation timed out
|
e_WOULD_BLOCK |
indicates operation would block (tryWait )
|
e_FAILED |
indicates failure reported from condition
|
Constructor & Destructor Documentation
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
Create a FastPostSemaphoreImpl
object initially having a count of 0. 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-level documentation). If clockType
is not specified then the realtime system clock is used.
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
Create a FastPostSemaphoreImpl
object initially having the specified count
. 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.
Member Function Documentation
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
Disable waiting on this semaphore. All subsequent invocations of wait
, tryWait
, and timedWait
will fail immediately. All blocked invocations of wait
and timedWait
will fail immediately. If the semaphore is initially disabled, this call has no effect.
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
Enable waiting on this semaphore. If the semaphore is initially enabled, this call has no effect.
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
Atomically increment the count of this semaphore.
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
Atomically increase the count of this semaphore by the specified value
. The behavior is undefined unless value > 0
.
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
If the count of this semaphore is positive, reduce the count by the lesser of the count and the specified maximumToTake
and return the magnitude of the change to the count. Otherwise, do nothing and return 0.
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
If the count of this semaphore is positive, reduce the count to 0 and return the original value of the count. Otherwise, do nothing and return 0.
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
If this semaphore is initially disabled, or becomes disabled while blocking, return e_DISABLED
with no effect on the count. Otherwise, block until the count of this semaphore is a positive value or the specified absTime
timeout expires. If the count of this semaphore is a positive value, return 0 and atomically decrement the count. If the absTime
timeout expires, return e_TIMED_OUT
with no effect on the count. Return e_FAILED
if an error occurs. 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 documentation).
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
If this semaphore is initially disabled, return e_DISABLED
with no effect on the count. Otherwise, if the count of this semaphore is a positive value, return 0 and atomically decrement the count. If this semaphore is not disabled and the count of this semaphore is not a positive value, return e_WOULD_BLOCK
with no effect on the count.
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
If this semaphore is initially disabled, or becomes disabled while blocking, return e_DISABLED
with no effect on the count. Otherwise, block until the count of this semaphore is a positive value, return 0 and atomically decrement the count. Return e_FAILED
if an error occurs.
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
Return the clock type used for timeouts.
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
Return an odd value if this semaphore is wait disabled, and an even value otherwise. The returned value can be used to detect a rapid short sequence of disable
and enable
invocations by comparing the value returned by getDisabledState
before and after the sequence. For example, for any initial state of a semphore instance obj
:
int state = obj.getDisabledState();
obj.disable();
obj.enable();
ASSERT(state != obj.getDisabledState());
This functionality is useful in higher-level components to determine if this semaphore was disabled during an operation.
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
Return the current value (count > 0 ? count : 0
) of this semaphore.
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
Return true
if this semaphore is wait disabled, and false
otherwise. Note that the semaphore is created in the "wait enabled" state.
Member Data Documentation
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
template<class ATOMIC_OP, class MUTEX, class CONDITION, class THREADUTIL>
The documentation for this class was generated from the following file: