Nazara Engine
0.4
A fast, complete, cross-platform API designed for game development
|
Core class that represents a counting semaphore. More...
Public Member Functions | |
Semaphore (unsigned int count) | |
Constructs a semaphore object with a count. | |
Semaphore (const Semaphore &)=delete | |
Semaphore (Semaphore &&) noexcept=default | |
~Semaphore () | |
Destructs the object. | |
unsigned int | GetCount () const |
Gets the number of count that can handle the semaphore. More... | |
void | Post () |
Increments the count of the semaphore and wait if count equals zero. More... | |
void | Wait () |
Decrements the count of the semaphore and wait if count equals zero. More... | |
bool | Wait (UInt32 timeout) |
Decrements the count of the semaphore and wait if count equals zero. More... | |
Semaphore & | operator= (const Semaphore &)=delete |
Semaphore & | operator= (Semaphore &&) noexcept=default |
Core class that represents a counting semaphore.
unsigned int Nz::Semaphore::GetCount | ( | ) | const |
Gets the number of count that can handle the semaphore.
void Nz::Semaphore::Post | ( | ) |
Increments the count of the semaphore and wait if count equals zero.
Increments the value of semaphore variable by 1. After the increment, if the pre-increment value was negative (meaning there are processes waiting for a resource), it transfers a blocked process from the semaphore's waiting queue to the ready queue
void Nz::Semaphore::Wait | ( | ) |
Decrements the count of the semaphore and wait if count equals zero.
If the value of semaphore variable is not negative, decrements it by 1. If the semaphore variable is now negative, the process executing Wait is blocked (i.e., added to the semaphore's queue) until the value is greater or equal to 1. Otherwise, the process continues execution, having used a unit of the resource
bool Nz::Semaphore::Wait | ( | UInt32 | timeout | ) |
Decrements the count of the semaphore and wait if count equals zero.
If the value of semaphore variable is not negative, decrements it by 1. If the semaphore variable is now negative, the process executing Wait is blocked (i.e., added to the semaphore's queue) until the value is greater or equal to 1. Otherwise, the process continues execution, having used a unit of the resource