SleepHelper
Public Member Functions
SleepHelper::SleepHelperRecursiveMutex Class Reference

This is a wrapper around a recursive mutex, similar to Device OS RecursiveMutex. More...

#include <SleepHelper.h>

Public Member Functions

 SleepHelperRecursiveMutex (os_mutex_recursive_t handle)
 Construct a SleepHelperRecursiveMutex wrapper object from an existing recursive mutex. More...
 
 SleepHelperRecursiveMutex ()
 Default constructor with no mutex - one will be created on first lock.
 
 ~SleepHelperRecursiveMutex ()
 Destroys the underlying mutex object.
 
void dispose ()
 Destroys the mutex object.
 
void lock () const
 Locks the mutex. Creates a new recursive mutex object if it does not exist yet. More...
 
bool trylock () const
 Attempts to lock the mutex. Creates a new recursive mutex object if it does not exist yet. More...
 
bool try_lock () const
 Attempts to lock the mutex. Creates a new recursive mutex object if it does not exist yet. More...
 
void unlock () const
 Unlocks the mutex. More...
 

Detailed Description

This is a wrapper around a recursive mutex, similar to Device OS RecursiveMutex.

There are two differences:

Constructor & Destructor Documentation

◆ SleepHelperRecursiveMutex()

SleepHelper::SleepHelperRecursiveMutex::SleepHelperRecursiveMutex ( os_mutex_recursive_t  handle)
inline

Construct a SleepHelperRecursiveMutex wrapper object from an existing recursive mutex.

Parameters
handleThe mutex handle

Ownership of the mutex handle is transferred to this object and it will be destroyed when this object is deleted.

Member Function Documentation

◆ lock()

void SleepHelper::SleepHelperRecursiveMutex::lock ( ) const
inline

Locks the mutex. Creates a new recursive mutex object if it does not exist yet.

Blocks if another thread has obtained the mutex, continues when the other thread releases it.

Never call lock from a SINGLE_THREADED_BLOCK since deadlock can occur.

◆ try_lock()

bool SleepHelper::SleepHelperRecursiveMutex::try_lock ( ) const
inline

Attempts to lock the mutex. Creates a new recursive mutex object if it does not exist yet.

Returns true if the mutex was locked or false if another thread has already locked it.

◆ trylock()

bool SleepHelper::SleepHelperRecursiveMutex::trylock ( ) const
inline

Attempts to lock the mutex. Creates a new recursive mutex object if it does not exist yet.

Returns true if the mutex was locked or false if another thread has already locked it.

◆ unlock()

void SleepHelper::SleepHelperRecursiveMutex::unlock ( ) const
inline

Unlocks the mutex.

If another thread is blocked on locking the mutex, that thread will resume.


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