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

RAII wrapper around an oveRTOS recursive mutex. More...

#include <sync.hpp>

Public Member Functions

 RecursiveMutex ()
 Constructs and initialises the recursive mutex.
 
 ~RecursiveMutex ()
 Destroys the recursive mutex, releasing the underlying kernel resource.
 
 RecursiveMutex (const RecursiveMutex &)=delete
 
RecursiveMutexoperator= (const RecursiveMutex &)=delete
 
 RecursiveMutex (RecursiveMutex &&other) noexcept
 Move constructor — transfers ownership of the kernel handle.
 
RecursiveMutexoperator= (RecursiveMutex &&other) noexcept
 Move-assignment operator — transfers ownership of the kernel handle.
 
int lock (uint32_t timeout_ms=OVE_WAIT_FOREVER)
 Acquires the recursive mutex.
 
void unlock ()
 Releases one level of the recursive lock.
 
bool valid () const
 Returns true if the underlying kernel handle is non-null.
 
ove_mutex_t handle () const
 Returns the raw oveRTOS mutex handle.
 

Detailed Description

RAII wrapper around an oveRTOS recursive mutex.

A recursive mutex may be locked multiple times by the same thread without deadlocking; each lock call must be paired with a matching unlock call. Ownership and zero-heap behaviour mirror that of Mutex.

Note
Not copyable. Move-only when heap allocation is enabled.

Constructor & Destructor Documentation

◆ RecursiveMutex() [1/2]

ove::RecursiveMutex::RecursiveMutex ( )
inline

Constructs and initialises the recursive mutex.

Calls ove_recursive_mutex_init (zero-heap) or ove_recursive_mutex_create (heap). Asserts at startup on failure.

◆ RecursiveMutex() [2/2]

ove::RecursiveMutex::RecursiveMutex ( RecursiveMutex &&  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=()

RecursiveMutex & ove::RecursiveMutex::operator= ( RecursiveMutex &&  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.

◆ lock()

int ove::RecursiveMutex::lock ( uint32_t  timeout_ms = OVE_WAIT_FOREVER)
inline

Acquires the recursive mutex.

Parameters
[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::RecursiveMutex::valid ( ) const
inline

Returns true if the underlying kernel handle is non-null.

Returns
true when the mutex was successfully initialised.

◆ handle()

ove_mutex_t ove::RecursiveMutex::handle ( ) const
inline

Returns the raw oveRTOS mutex handle.

Returns
The opaque ove_mutex_t handle.

The documentation for this class was generated from the following file: