Provides a general counting semaphore. More...
#include <Radiant/Semaphore.hpp>
Public Member Functions | |
| void | acquire (int n=1) |
| Try to acquire resources. More... | |
| void | release (int n=1) |
| Release resources. More... | |
| Semaphore (int n=0) | |
| Initialize the semaphore to guard n resources. More... | |
| bool | tryAcquire (int n=1) |
| Try to acquire resources. More... | |
| bool | tryAcquire (int n, int timeoutMs) |
| Try to acquire resources. More... | |
| ~Semaphore () | |
| Destructor. | |
Provides a general counting semaphore.
| Radiant::Semaphore::Semaphore | ( | int | n = 0 | ) |
Initialize the semaphore to guard n resources.
| n | number of resources to guard (default 0) |
| void Radiant::Semaphore::acquire | ( | int | n = 1 | ) |
Try to acquire resources.
This will block until available() >= n.
| n | number of resources to acquire |
| void Radiant::Semaphore::release | ( | int | n = 1 | ) |
Release resources.
| n | number of resources to release |
| bool Radiant::Semaphore::tryAcquire | ( | int | n = 1 | ) |
Try to acquire resources.
Does not block.
| n | number of resources to acquire |
| bool Radiant::Semaphore::tryAcquire | ( | int | n, |
| int | timeoutMs | ||
| ) |
Try to acquire resources.
This call will block for at most the given timeout if available() < n.
| n | number of resources to acquire |
| timeoutMs | time to wait for resources if they are not avaible |