FreeRTOScpp
Loading...
Searching...
No Matches
Mutex Class Reference

Mutex Wrapper. More...

#include <MutexCPP.h>

Inheritance diagram for Mutex:
Collaboration diagram for Mutex:

Public Member Functions

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

Private Member Functions

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

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();
Recursive Mutex Wrapper.
Definition MutexCPP.h:160

Constructor & Destructor Documentation

◆ Mutex() [1/2]

Mutex::Mutex ( char const * name)
inline

Constructor.

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

◆ ~Mutex()

Mutex::~Mutex ( )
inline

Destructor.

Deletes the semaphore.

◆ Mutex() [2/2]

Mutex::Mutex ( Mutex const & )
privatedelete

We are not copyable.

Member Function Documentation

◆ give()

bool Mutex::give ( )
inlineoverridevirtual

Implements Lockable.

◆ operator=()

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

We are not assignable.

◆ take()

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

Implements Lockable.

Member Data Documentation

◆ mutexHandle

SemaphoreHandle_t Mutex::mutexHandle
private

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