A specialization of a counting_semaphore handling only a single permit. Same as binary_semaphore.
More...
#include <coopsync_tbb/semaphore.hpp>
|
| static constexpr std::ptrdiff_t | max () noexcept |
| | Returns the maximum value for the counter of the binary semaphore.
|
A specialization of a counting_semaphore handling only a single permit. Same as binary_semaphore.
◆ counting_semaphore()
Constructs a counting_semaphore with the specified initial count.
- Parameters
-
| desired | The initial count. Must be 0 or 1. |
◆ ~counting_semaphore()
Destroys the counting_semaphore.
- Note
- The destructor must not be called while there are still tasks waiting on the counting_semaphore. The destructor does not notify or resume any waiting tasks.
◆ acquire()
Acquires the semaphore. If the semaphore is already acquired the calling task is suspended until the semaphore is released.
- Note
- The suspended task must remain valid until it is resumed.
-
The suspended task must be resumed before the binary_semaphore is destroyed.
◆ max()
|
|
inlinestaticconstexprnoexcept |
Returns the maximum value for the counter of the binary semaphore.
- Returns
- Always returns 1.
◆ release()
Releases the semaphore incrementing the counter by the specified update. If there are tasks suspended on the semaphore and the counter becomes greater than zero, one of them is resumed.
- Parameters
-
| update | The value to increment the counter by. Must be non-negative, all positive values are treated as 1. |
◆ try_acquire()
Attempts to acquire the semaphore without suspending.
- Returns
- true if the semaphore was successfully acquired, false otherwise.
The documentation for this class was generated from the following file: