Template Class SemaphoreGuard
Defined in File semaphore.hpp
Class Documentation
-
template<typename T>
class SemaphoreGuard RAII guard for operations with a semaphore. On creation, the semaphore is acquired, and on destruction, it is released.
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;
- Template Parameters:
T – Type of the semaphore. Can be any type with methods
bool acquire()andvoid release().