|
| | Mutex () |
| | Constructs and initialises the mutex.
|
| |
| | ~Mutex () noexcept |
| | Destroys the mutex, releasing the underlying kernel resource.
|
| |
|
| Mutex (const Mutex &)=delete |
| |
|
Mutex & | operator= (const Mutex &)=delete |
| |
| | Mutex (Mutex &&other) noexcept |
| | Move constructor — transfers ownership of the kernel handle.
|
| |
| Mutex & | operator= (Mutex &&other) noexcept |
| | Move-assignment operator — transfers ownership of the kernel handle.
|
| |
| void | lock () |
| | Acquires the mutex, blocking indefinitely. std::mutex::lock analog.
|
| |
| bool | try_lock () |
| | Attempts to acquire the mutex without blocking. Satisfies the Lockable named requirement (alongside lock / unlock).
|
| |
| template<class Rep , class Period > |
| Result< void > | try_lock_for (const std::chrono::duration< Rep, Period > &rel) noexcept |
| | Attempts to acquire the mutex within rel.
|
| |
| template<class Clock , class Duration > |
| Result< void > | try_lock_until (const std::chrono::time_point< Clock, Duration > &deadline) noexcept |
| | Attempts to acquire the mutex by deadline.
|
| |
| void | unlock () |
| | Releases the mutex.
|
| |
| bool | valid () const |
| | Returns true if the underlying kernel handle is non-null.
|
| |
| ove_mutex_t | handle () const |
| | Returns the raw oveRTOS mutex handle.
|
| |
RAII wrapper around an oveRTOS non-recursive mutex.
Constructs the underlying kernel mutex object on creation and destroys it on destruction. With CONFIG_OVE_ZERO_HEAP the mutex storage is held inline in the wrapper; move operations are therefore disabled in that configuration because the kernel may hold a pointer to the internal buffer.
- Note
- Not copyable. Move-only when heap allocation is enabled.
-
lock() is marked [[nodiscard]]; ignoring its return value risks deadlock.
| void ove::Mutex::lock |
( |
| ) |
|
|
inline |
Acquires the mutex, blocking indefinitely. std::mutex::lock analog.
Failure of an indefinite lock means the handle is unusable (moved-from, stale, or subsystem mid-deinit) — programming error, not a recoverable runtime condition. Aborts via OVE_STATIC_INIT_ASSERT on non-OK return; mirrors how Thread / Queue constructors handle similar failures.
Pairs with try_lock to satisfy the Lockable named requirement, enabling std::lock_guard<ove::Mutex> and std::scoped_lock(m1, m2) composition. Does not satisfy TimedLockable — try_lock_for and try_lock_until return Result<void> not bool, so std::unique_lock<> 's timeout overloads won't compile. Use those methods directly and switch on the Result instead.
template<class Rep , class Period >
| Result< void > ove::Mutex::try_lock_for |
( |
const std::chrono::duration< Rep, Period > & |
rel | ) |
|
|
inlinenoexcept |
Attempts to acquire the mutex within rel.
Templated over std::chrono::duration so any unit composes (100ms, 1s, 2us …). Does not satisfy the TimedLockable named requirement — that requires a bool return; this returns Result<void> so timeout (Error::Timeout) and substrate errors are reported distinctly. Consequence: std::unique_lock<ove::Mutex>::try_lock_for won't compile — use this method directly and switch on the Result instead.
- Parameters
-
| [in] | rel | Relative 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.