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 () noexcept
 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.
 
void lock ()
 Acquires the recursive mutex, blocking indefinitely.
 
bool try_lock ()
 Non-blocking acquisition attempt. Part of the Lockable named requirement satisfied by this class.
 
template<class Rep , class Period >
Result< void > try_lock_for (const std::chrono::duration< Rep, Period > &rel) noexcept
 Bounded-wait acquisition. Same shape as Mutex::try_lock_for — see that method for the TimedLockable non-satisfaction rationale.
 
template<class Clock , class Duration >
Result< void > try_lock_until (const std::chrono::time_point< Clock, Duration > &deadline) noexcept
 Deadline-based acquisition templated over the clock.
 
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()

void ove::RecursiveMutex::lock ( )
inline

Acquires the recursive mutex, blocking indefinitely.

Same fatal-on-failure semantics as Mutex::lock.

◆ try_lock()

bool ove::RecursiveMutex::try_lock ( )
inline

Non-blocking acquisition attempt. Part of the Lockable named requirement satisfied by this class.

Returns
true on acquisition (or recursive re-acquisition), false if the mutex is held by another thread.

◆ try_lock_for()

template<class Rep , class Period >
Result< void > ove::RecursiveMutex::try_lock_for ( const std::chrono::duration< Rep, Period > &  rel)
inlinenoexcept

Bounded-wait acquisition. Same shape as Mutex::try_lock_for — see that method for the TimedLockable non-satisfaction rationale.

Parameters
[in]relRelative timeout (any std::chrono::duration unit).
Returns
Empty Result<void> on acquisition; unexpected Error::Timeout if the deadline elapsed without the lock being acquired; unexpected with another Error value on backend failure.

◆ try_lock_until()

template<class Clock , class Duration >
Result< void > ove::RecursiveMutex::try_lock_until ( const std::chrono::time_point< Clock, Duration > &  deadline)
inlinenoexcept

Deadline-based acquisition templated over the clock.

Same clock-templating rationale as Mutex::try_lock_until (deadline converted to a relative duration internally).

Returns
As try_lock_forResult<void> with Error::Timeout on timeout.

◆ 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: