|
| | Semaphore (unsigned int initial=0, unsigned int max=1) |
| | Constructs and initialises the semaphore.
|
| |
|
| ~Semaphore () noexcept |
| | Destroys the semaphore, releasing the underlying kernel resource.
|
| |
|
| Semaphore (const Semaphore &)=delete |
| |
|
Semaphore & | operator= (const Semaphore &)=delete |
| |
| | Semaphore (Semaphore &&other) noexcept |
| | Move constructor — transfers ownership of the kernel handle.
|
| |
| Semaphore & | operator= (Semaphore &&other) noexcept |
| | Move-assignment operator — transfers ownership of the kernel handle.
|
| |
| void | acquire () |
| | Decrements the semaphore count, blocking indefinitely.
|
| |
| bool | try_acquire () |
| | Non-blocking acquisition attempt. std::counting_semaphore::try_acquire analog.
|
| |
| template<class Rep , class Period > |
| Result< void > | try_acquire_for (const std::chrono::duration< Rep, Period > &rel) noexcept |
| | Bounded-wait acquisition.
|
| |
| template<class Clock , class Duration > |
| Result< void > | try_acquire_until (const std::chrono::time_point< Clock, Duration > &deadline) noexcept |
| | Deadline-based acquisition templated over the clock.
|
| |
| void | release () |
| | Increments the semaphore count, unblocking a waiting task if any.
|
| |
| bool | valid () const |
| | Returns true if the underlying kernel handle is non-null.
|
| |
| ove_sem_t | handle () const |
| | Returns the raw oveRTOS semaphore handle.
|
| |
RAII wrapper around an oveRTOS counting semaphore.
A counting semaphore with a configurable initial count and maximum count. Commonly used as a binary semaphore (initial = 0, max = 1) for signalling between tasks or from an ISR.
With CONFIG_OVE_ZERO_HEAP the semaphore storage is held inline and move operations are disabled.
- Note
- Not copyable. Move-only when heap allocation is enabled.
-
take() is marked [[nodiscard]]; the return value indicates whether the semaphore was actually decremented.
template<class Rep , class Period >
| Result< void > ove::Semaphore::try_acquire_for |
( |
const std::chrono::duration< Rep, Period > & |
rel | ) |
|
|
inlinenoexcept |
Bounded-wait acquisition.
Loosely analogous to std::counting_semaphore::try_acquire_for but with a Result<void> return instead of bool — timeout and backend errors are reported distinctly via Error. This means std::counting_semaphore's interface is not strictly satisfied; the standard has no concept for it, so the mismatch shows up only if you try to substitute the type into a generic template that expects the standard shape.
- Parameters
-
| [in] | rel | Relative timeout (any std::chrono::duration unit). |
- Returns
- Empty
Result<void> on acquisition; unexpected Error::Timeout if the count was zero at the deadline; unexpected with another Error value on backend failure.