Alexandria 2.31.0
SDC-CH common library for the Euclid project
|
#include <Semaphore.h>
Public Member Functions | |
Semaphore (unsigned int i) | |
~Semaphore () | |
void | release () |
void | acquire () |
bool | try_acquire () |
bool | try_acquire_until (const std::chrono::system_clock::time_point &abs_time) |
template<class Clock , class Duration > | |
bool | try_acquire_until (const std::chrono::time_point< Clock, Duration > &abs_time) |
template<class Rep , class Ratio > | |
bool | try_acquire_for (const std::chrono::duration< Rep, Ratio > &rel_time) |
Private Attributes | |
std::unique_ptr< SemaphoreImpl > | m_impl |
Counting semaphore, based on the C++20 API, so it can be eventually swapped
Definition at line 31 of file Semaphore.h.
|
explicit |
Constructor
i | The internal counter will be initialized to i |
Definition at line 28 of file Semaphore.cpp.
|
default |
Destructor
void Euclid::Semaphore::acquire | ( | ) |
Decrement the counter. Blocks if it was already 0 until some other thread calls release()
Definition at line 36 of file Semaphore.cpp.
References m_impl.
void Euclid::Semaphore::release | ( | ) |
Increment the counter. Does not block.
Definition at line 32 of file Semaphore.cpp.
References m_impl.
bool Euclid::Semaphore::try_acquire | ( | ) |
Try decrementing the counter.
Definition at line 40 of file Semaphore.cpp.
References m_impl.
|
inline |
Try decrementing the counter with a relative timeout
Rep | |
Ratio |
rel_time | If the counter can not be decremented, the call will block for this duration. |
Definition at line 94 of file Semaphore.h.
References std::chrono::system_clock::now(), and try_acquire_until().
bool Euclid::Semaphore::try_acquire_until | ( | const std::chrono::system_clock::time_point & | abs_time | ) |
Try decrementing the counter with an absolute timeout
abs_time | If the counter can not be decremented, the call will block until this time point is reached. If it was in the past, it will return immediately. |
Definition at line 44 of file Semaphore.cpp.
References m_impl.
Referenced by try_acquire_for(), and try_acquire_until().
|
inline |
Clock | |
Duration |
abs_time |
Definition at line 80 of file Semaphore.h.
References std::chrono::system_clock::now(), and try_acquire_until().
|
private |
Definition at line 100 of file Semaphore.h.
Referenced by acquire(), release(), try_acquire(), and try_acquire_until().