RAII guard for operations with a semaphore. On creation, the semaphore is acquired, and on destruction, it is released.
More...
template<typename T>
class cras::SemaphoreGuard< T >
RAII guard for operations with a semaphore. On creation, the semaphore is acquired, and on destruction, it is released.
- Template Parameters
-
T | Type of the semaphore. Can be any type with methods bool acquire() and void release() . |
- Note
- The usage pattern is slightly different than the normal lock_guard - because acquire() can return false (e.g. if the semaphore is blocked for new acquisitions), the pattern should be the following: `SemaphoreGuard<ReverseSemaphore> guard(sem); if (!guard.acquired()) return;
Definition at line 109 of file semaphore.hpp.