ORIGINAL
|
RAII wrapper for automatic semaphore management. More...
#include <semaphores.h>
Public Member Functions | |
semaphoreGuard (semaphore< MAX_CNT > &sem) | |
Constructs a guard and acquires the semaphore. | |
~semaphoreGuard () | |
Destructor that releases the semaphore. | |
RAII wrapper for automatic semaphore management.
MAX_CNT | Maximum semaphore count (matches semaphore template parameter) |
Acquires the semaphore on construction and automatically releases it on destruction. Ensures exception-safe semaphore usage and prevents resource leaks.
|
explicit |
Constructs a guard and acquires the semaphore.
sem | Semaphore to manage |
Calls sem.acquire() during construction
original::semaphoreGuard< MAX_CNT >::~semaphoreGuard | ( | ) |
Destructor that releases the semaphore.
Calls sem.release() during destruction