Base Framework
|
Semaphore synchronization object. More...
#include <base/concurrency/Semaphore.h>
Inherits Resource.
Public Member Functions | |
Semaphore (unsigned int value=0) | |
int | getValue () const |
void | post () |
void | wait () const |
bool | tryWait () const |
~Semaphore () | |
![]() | |
String | getDescription () const |
void | setDescription (const String &description) |
unsigned int | getResourceId () const |
unsigned int | getCreatedById () const |
AnyReference | getHandle () const noexcept |
template<class TYPE > | |
TYPE & | getInternalHandle () const |
operator bool () const noexcept | |
Static Public Member Functions | |
static unsigned int | getMaximum () noexcept |
Additional Inherited Members | |
![]() | |
AnyReference | handle |
Semaphore synchronization object.
Semaphore synchronization object. Semaphores are useful when resources need to be synchronized between multiple threads.
Semaphore::Semaphore | ( | unsigned int | value = 0 | ) |
Initializes the semaphore object. Raises OutOfDomain if the value exceeds the maximum value.
value | The initial value. The default is 0. |
Semaphore::~Semaphore | ( | ) |
Destroys the semaphore object.
|
staticnoexcept |
Returns the maximum value the semaphore may have. The maximum value is guaranteed to be greater than or equal to 32767 and less then or equal to Primitive<int>::MAXIMUM.
int Semaphore::getValue | ( | ) | const |
Returns the current value of the semaphore. Warning: this method may not be supported on the particular platform.
void Semaphore::post | ( | ) |
Increments the semaphore and signals any thread waiting for a change. This method never blocks.
bool Semaphore::tryWait | ( | ) | const |
Non-blocking variant of wait.
void Semaphore::wait | ( | ) | const |
Decrements the semaphore and blocks if the semaphore is less than zero until another thread signals a change.