EtcPal
HEAD (unstable)
ETC Platform Abstraction Layer (EtcPal)
|
View other versions:
|
A wrapper class for the EtcPal recursive mutex type.
WARNING: Recursive mutexes are rarely necessary for new code. They are often used to retrofit thread-safety into existing code. They can hide nasty bugs. Use regular etcpal::Mutex whenever possible.
Note: The etcpal::RecursiveMutex functions are not normally used directly - prefer usage of the RAII type etcpal::RecursiveMutexGuard to manage locking and unlocking of an etcpal::RecursiveMutex.
See etcpal::Mutex for example usage.
See recursive_mutex (Recursive Mutexes) for more information on the recursive mutex time.
Public Member Functions | |
RecursiveMutex () | |
Create a new recursive mutex. | |
~RecursiveMutex () | |
Destroy the recursive mutex. | |
RecursiveMutex (const RecursiveMutex &other)=delete | |
RecursiveMutex & | operator= (const RecursiveMutex &other)=delete |
RecursiveMutex (RecursiveMutex &&other)=delete | |
RecursiveMutex & | operator= (RecursiveMutex &&other)=delete |
bool | Lock () |
Lock the mutex. More... | |
bool | TryLock (int timeout_ms=0) |
Attempt to lock the recursive mutex. More... | |
void | Unlock () |
Unlock the recursive mutex. More... | |
etcpal_recursive_mutex_t & | get () |
Get a reference to the underlying etcpal_recursive_mutex_t type. | |
|
inline |
Lock the mutex.
|
inline |
Attempt to lock the recursive mutex.
Returns when either the mutex is acquired or the timeout expires. NOTE: Timeout values other than 0 or ETCPAL_WAIT_FOREVER are typically only honored on real-time platforms. See the table in recursive_mutex (Recursive Mutexes) for more information. On platforms where timeouts are not honored, passing 0 for timeout_ms executes a poll for the mutex returning immediately, while any other value executes the equivalent of Lock().
timeout_ms | How long to wait to acquire the mutex, in milliseconds. Default is to poll and return immediately. |
|
inline |
Unlock the recursive mutex.