#include <timed_mutex.h>
Public Member Functions | |
TimedMutex (const TimedMutex &)=delete | |
TimedMutex (TimedMutex &&)=delete | |
TimedMutex & | operator= (const TimedMutex &)=delete |
TimedMutex & | operator= (TimedMutex &&)=delete |
bool | try_lock_for (chrono::SystemClock::duration timeout) |
bool | try_lock_until (chrono::SystemClock::time_point deadline) |
![]() | |
Mutex (const Mutex &)=delete | |
Mutex (Mutex &&)=delete | |
Mutex & | operator= (const Mutex &)=delete |
Mutex & | operator= (Mutex &&)=delete |
void | lock () |
bool | try_lock () |
void | unlock () |
native_handle_type | native_handle () |
Additional Inherited Members | |
![]() | |
using | native_handle_type = backend::NativeMutexHandle |
![]() | |
backend::NativeMutex & | native_type () |
const backend::NativeMutex & | native_type () const |
The TimedMutex
is a synchronization primitive that can be used to protect shared data from being simultaneously accessed by multiple threads with timeouts and deadlines, extending the Mutex
. It offers exclusive, non-recursive ownership semantics where priority inheritance is used to solve the classic priority-inversion problem. This is thread safe, but NOT IRQ safe.
embed:rst:leading-asterisk * .. warning:: * In order to support global statically constructed TimedMutexes, the user * and/or backend MUST ensure that any initialization required in your * environment is done prior to the creation and/or initialization of the * native synchronization primitives (e.g. kernel initialization). *
bool pw::sync::TimedMutex::try_lock_for | ( | chrono::SystemClock::duration | timeout | ) |
Tries to lock the mutex. Blocks until specified the timeout has elapsed or the lock is acquired, whichever comes first. Returns true if the mutex was successfully acquired.
PRECONDITION: The lock isn't already held by this thread. Recursive locking is undefined behavior.
bool pw::sync::TimedMutex::try_lock_until | ( | chrono::SystemClock::time_point | deadline | ) |
Tries to lock the mutex. Blocks until specified deadline has been reached or the lock is acquired, whichever comes first. Returns true if the mutex was successfully acquired.
PRECONDITION: The lock isn't already held by this thread. Recursive locking is undefined behavior.