|
Dev Essential
1.6.3
|
#include <semaphore_decl.h>
Public Member Functions | |
| basic_semaphore (int count=0) | |
| void | notify () |
| Increment the counter and notify any waiters. | |
| void | wait () |
| Decrement the counter, blocks until the count becomes non-zero (if neccessary) | |
| bool | try_wait () |
| template<typename Rep, typename Period> | |
| bool | wait_for (const std::chrono::duration< Rep, Period > &timeout) |
| void | reset () |
| Reset the counter to 0. | |
| bool | is_set () |
Protected Attributes | |
| Mutex | _mutex |
| The mutex to handle. | |
| CondVar | _cv |
| The condition variable used to handle the notifications. | |
| int | _lock_count |
| The lock count. | |
Semaphore implementation, combining a mutex and a condition variable to manage a counter
For the default semaphore type to use, check a_util::concurrency::semaphore.
| Mutex | The mutex type |
| CondVar | The condition variable type |
|
inlineexplicit |
CTOR
| [in] | count | Initial value of the counter |
|
inline |
Check whether the counter is set.
true if the counter is greater than zero, false otherwise.
|
inline |
Try decrementing the counter
true if the counter is greater than zero, false otherwise
|
inline |
Wait for a specified duration of time and decrement the counter afterwards
| Rep | An arithmetic type representing the number of ticks |
| std::ratio | representing the tick period (i.e. the number of seconds per tick) |
| [in] | timeout | The duration to wait. |
| std::invalid_argument | If timeout.count < 0 |
true if the counter could be decreased after the waiting time, false otherwise