Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
RAII wrapper class for std::binary_semaphore. More...
#include <src/utils/concurrency.h>
Public Member Functions | |
SemaphoreRAII (SemaphoreType &semaphore, bool force_acquire=false) | |
Constructor that attempts to acquire the semaphore. | |
~SemaphoreRAII () | |
Destructor that releases the semaphore if it was acquired. | |
SemaphoreRAII (const SemaphoreRAII &)=delete | |
SemaphoreRAII & | operator= (const SemaphoreRAII &)=delete |
SemaphoreRAII (SemaphoreRAII &&)=default | |
SemaphoreRAII & | operator= (SemaphoreRAII &&)=default |
bool | try_acquire () |
Attempts to acquire the semaphore if it hasn't been acquired already. | |
void | release () |
Releases the semaphore if it was previously acquired. | |
bool | is_acquired () const |
Checks if the semaphore is currently acquired by the wrapper object. |
RAII wrapper class for std::binary_semaphore.
This class provides a convenient and safe way to acquire and release a binary semaphore using the RAII (Resource Acquisition Is Initialization) idiom. It ensures that the semaphore is properly released when the wrapper object goes out of scope.
Definition at line 60 of file concurrency.h.
|
inlineexplicit |
Constructor that attempts to acquire the semaphore.
semaphore | The semaphore to acquire. |
Definition at line 68 of file concurrency.h.
|
inline |
Destructor that releases the semaphore if it was acquired.
Definition at line 101 of file concurrency.h.
|
inline |
Checks if the semaphore is currently acquired by the wrapper object.
Definition at line 169 of file concurrency.h.
|
inline |
Releases the semaphore if it was previously acquired.
Definition at line 147 of file concurrency.h.
|
inline |
Attempts to acquire the semaphore if it hasn't been acquired already.
Definition at line 127 of file concurrency.h.