RAII wrapper around an oveRTOS condition variable.
More...
#include <sync.hpp>
|
| | CondVar () |
| | Constructs and initialises the condition variable.
|
| |
|
| ~CondVar () |
| | Destroys the condition variable, releasing the underlying kernel resource.
|
| |
|
| CondVar (const CondVar &)=delete |
| |
|
CondVar & | operator= (const CondVar &)=delete |
| |
| | CondVar (CondVar &&other) noexcept |
| | Move constructor — transfers ownership of the kernel handle.
|
| |
| CondVar & | operator= (CondVar &&other) noexcept |
| | Move-assignment operator — transfers ownership of the kernel handle.
|
| |
| int | wait (Mutex &mtx, uint32_t timeout_ms=OVE_WAIT_FOREVER) |
| | Atomically releases the mutex and waits for a notification.
|
| |
|
void | signal () |
| | Wakes one task waiting on this condition variable.
|
| |
|
void | broadcast () |
| | Wakes all tasks waiting on this condition variable.
|
| |
| bool | valid () const |
| | Returns true if the underlying kernel handle is non-null.
|
| |
| ove_condvar_t | handle () const |
| | Returns the raw oveRTOS condition variable handle.
|
| |
RAII wrapper around an oveRTOS condition variable.
A condition variable allows tasks to efficiently wait for a predicate to become true. It must always be used together with a Mutex — the mutex is atomically released while waiting and re-acquired before wait() returns.
- Note
- Not copyable. Move-only when heap allocation is enabled.
-
Always check the predicate in a loop after
wait() to guard against spurious wake-ups.
◆ CondVar() [1/2]
| ove::CondVar::CondVar |
( |
| ) |
|
|
inline |
Constructs and initialises the condition variable.
Asserts at startup if initialisation fails.
◆ CondVar() [2/2]
| ove::CondVar::CondVar |
( |
CondVar && |
other | ) |
|
|
inlinenoexcept |
Move constructor — transfers ownership of the kernel handle.
- Parameters
-
| other | The source; its handle is set to null after the move. |
◆ operator=()
Move-assignment operator — transfers ownership of the kernel handle.
- Parameters
-
| other | The source; its handle is set to null after the move. |
- Returns
- Reference to this object.
◆ wait()
| int ove::CondVar::wait |
( |
Mutex & |
mtx, |
|
|
uint32_t |
timeout_ms = OVE_WAIT_FOREVER |
|
) |
| |
|
inline |
Atomically releases the mutex and waits for a notification.
The calling task must hold mtx before calling this method. The mutex is released atomically while the task blocks, and re-acquired before the call returns.
- Parameters
-
| [in] | mtx | The mutex associated with the predicate being waited on. |
| [in] | timeout_ms | Maximum wait time in milliseconds; use OVE_WAIT_FOREVER to block indefinitely. |
- Returns
OVE_OK on success, or a negative error code on timeout/failure.
◆ valid()
| bool ove::CondVar::valid |
( |
| ) |
const |
|
inline |
Returns true if the underlying kernel handle is non-null.
- Returns
true when the condition variable was successfully initialised.
◆ handle()
| ove_condvar_t ove::CondVar::handle |
( |
| ) |
const |
|
inline |
Returns the raw oveRTOS condition variable handle.
- Returns
- The opaque
ove_condvar_t handle.
The documentation for this class was generated from the following file: