TracktionEngine
|
A counting semaphore that spins on a atomic before waiting so will avoid system calls if wait periods are very short. More...
#include <tracktion_Semaphore.h>
Public Member Functions | |
LightweightSemaphore (int initialCount=0) | |
Creates a semaphore with an initial count. | |
~LightweightSemaphore () | |
Destructor. | |
bool | wait () |
Decrements the count by one and if the result of this goes below zero the call will block. | |
bool | try_wait () |
Attemps to decrement the count by one. | |
bool | timed_wait (std::uint64_t usecs) |
Performs a wait operation. | |
void | signal (int count=1) |
Increases the count by the ammount specified. | |
A counting semaphore that spins on a atomic before waiting so will avoid system calls if wait periods are very short.
tracktion::graph::LightweightSemaphore::LightweightSemaphore | ( | int | initialCount = 0 | ) |
Creates a semaphore with an initial count.
tracktion::graph::LightweightSemaphore::~LightweightSemaphore | ( | ) |
Destructor.
bool tracktion::graph::LightweightSemaphore::wait | ( | ) |
Decrements the count by one and if the result of this goes below zero the call will block.
bool tracktion::graph::LightweightSemaphore::try_wait | ( | ) |
Attemps to decrement the count by one.
If the decrement leaves the count above zero this will return true. If the decrement would leave the count below zero this will not block and return false.
bool tracktion::graph::LightweightSemaphore::timed_wait | ( | std::uint64_t | usecs | ) |
Performs a wait operation.
If the wait would actually block, the block happens for the given period of time before returning or the semaphore is signalled, whichever happens first.
void tracktion::graph::LightweightSemaphore::signal | ( | int | count = 1 | ) |
Increases the count by the ammount specified.
If the count goes above zero, this will signal waiting threads, unblocking them.