FreeRTOScpp
FreeRTOScpp::Mutex Class Reference

Mutex Wrapper. More...

#include <MutexCPP.h>

Inheritance diagram for FreeRTOScpp::Mutex:
Collaboration diagram for FreeRTOScpp::Mutex:

Public Member Functions

 Mutex (char const *name)
 Constructor. More...
 
 ~Mutex ()
 Destructor. More...
 
bool give () override
 
bool take (TickType_t wait=portMAX_DELAY) override
 
bool take (Time_ms wait)
 

Private Member Functions

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

Private Attributes

SemaphoreHandle_t mutexHandle
 

Detailed Description

Mutex Wrapper.

A Mutex is a basic synchronization primitive allowing mutual exclusion to be handled which also implements priority inheritance. Note, the basic mutex is NOT recursive, ie if a Task has taken the Mutex, it must not try to take it again before giving it. If you need this, use a RecurviseMutex.

The usage of a Mutex is similar to a semaphore, but the task that takes the Mutex is also supposed to be the Task that eventually gives it back. It also doesn't normally make sense for an ISR to use a Mutex, so no _ISR routines have been made available.

Example Usage:

RecursiveMutex mutex("MyMutex");
// In some other task
mutex.take();
... // some code that needs mutual exclusion
mutex.give();

Constructor & Destructor Documentation

◆ Mutex() [1/2]

FreeRTOScpp::Mutex::Mutex ( char const *  name)
inline

Constructor.

Parameters
nameName to give mutex, used for Debug Registry if setup

References mutexHandle.

◆ ~Mutex()

FreeRTOScpp::Mutex::~Mutex ( )
inline

Destructor.

Deletes the semaphore.

References mutexHandle.

◆ Mutex() [2/2]

FreeRTOScpp::Mutex::Mutex ( Mutex const &  )
privatedelete

We are not copyable.

Member Function Documentation

◆ give()

bool FreeRTOScpp::Mutex::give ( )
inlineoverridevirtual

Implements FreeRTOScpp::Lockable.

References mutexHandle.

◆ operator=()

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

We are not assignable.

◆ take() [1/2]

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

Implements FreeRTOScpp::Lockable.

References mutexHandle.

◆ take() [2/2]

bool FreeRTOScpp::Mutex::take ( Time_ms  wait)
inline

References FreeRTOScpp::ms2ticks(), and mutexHandle.

Here is the call graph for this function:

Member Data Documentation

◆ mutexHandle


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