FreeRTOScpp
FreeRTOScpp::RecursiveMutex Class Reference

Recursive Mutex Wrapper. More...

#include <MutexCPP.h>

Inheritance diagram for FreeRTOScpp::RecursiveMutex:
Collaboration diagram for FreeRTOScpp::RecursiveMutex:

Public Member Functions

 RecursiveMutex (char const *name=nullptr)
 
 ~RecursiveMutex ()
 
bool give () override
 
bool take (Time_ms ms)
 
bool take (TickType_t wait=portMAX_DELAY) override
 

Private Member Functions

 RecursiveMutex (RecursiveMutex const &)=delete
 We are not copyable. More...
 
void operator= (RecursiveMutex const &)=delete
 We are not assignable. More...
 

Private Attributes

SemaphoreHandle_t mutexHandle
 

Detailed Description

Recursive Mutex Wrapper.

A RecursiveMutex adds the ability to nest takes, so that if you have taken the RecursiveMutex and take it again, this works and requires you to give the RecursiveMutex back as many times as it was taken before it is released.

One very common application for this is for messages to the user on a console. Generally, you don't want pieces of a message interrupted by pieces of other messages, so message output routines use a mutex on the console port. These routines often use lower level routines that also want to make sure their output isn't interspersed, so each level takes the RecursiveMutex at their start and releases it at the end. Being a RecursiveMutex this works.

Example Usage:

RecursiveMutex mutex("MyMutex");
// In some other task
mutex.take();
...
// possible in a recursive call or call to lower level routine.
mutex.take();
...
mutex.give();
...
mutex.give();

Constructor & Destructor Documentation

◆ RecursiveMutex() [1/2]

FreeRTOScpp::RecursiveMutex::RecursiveMutex ( char const *  name = nullptr)
inline

◆ ~RecursiveMutex()

FreeRTOScpp::RecursiveMutex::~RecursiveMutex ( )
inline

◆ RecursiveMutex() [2/2]

FreeRTOScpp::RecursiveMutex::RecursiveMutex ( RecursiveMutex const &  )
privatedelete

We are not copyable.

Member Function Documentation

◆ give()

bool FreeRTOScpp::RecursiveMutex::give ( )
inlineoverridevirtual

◆ operator=()

void FreeRTOScpp::RecursiveMutex::operator= ( RecursiveMutex const &  )
privatedelete

We are not assignable.

◆ take() [1/2]

bool FreeRTOScpp::Lockable::take ( Time_ms  ms)
inlineinherited

References FreeRTOScpp::Lockable::give(), FreeRTOScpp::Lockable::Lockable(), FreeRTOScpp::ms2ticks(), FreeRTOScpp::Lockable::operator=(), and FreeRTOScpp::Lockable::take().

Referenced by FreeRTOScpp::Lockable::take().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ take() [2/2]

bool FreeRTOScpp::RecursiveMutex::take ( TickType_t  wait = portMAX_DELAY)
inlineoverridevirtual

Member Data Documentation

◆ mutexHandle

SemaphoreHandle_t FreeRTOScpp::RecursiveMutex::mutexHandle
private

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