oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ove::CondVar Class Reference

RAII wrapper around an oveRTOS condition variable. More...

#include <sync.hpp>

Public Member Functions

 CondVar ()
 Constructs and initialises the condition variable.
 
 ~CondVar ()
 Destroys the condition variable, releasing the underlying kernel resource.
 
 CondVar (const CondVar &)=delete
 
CondVaroperator= (const CondVar &)=delete
 
 CondVar (CondVar &&other) noexcept
 Move constructor — transfers ownership of the kernel handle.
 
CondVaroperator= (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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ 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
otherThe source; its handle is set to null after the move.

Member Function Documentation

◆ operator=()

CondVar & ove::CondVar::operator= ( CondVar &&  other)
inlinenoexcept

Move-assignment operator — transfers ownership of the kernel handle.

Parameters
otherThe 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]mtxThe mutex associated with the predicate being waited on.
[in]timeout_msMaximum 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: