45#if FREERTOSCPP_USE_NAMESPACE
82#if( configSUPPORT_STATIC_ALLOCATION == 1 )
83 mutexHandle = xSemaphoreCreateMutexStatic(&mutexBuffer);
85 mutexHandle = xSemaphoreCreateMutex();
87#if configQUEUE_REGISTRY_SIZE > 0
88 vQueueAddToRegistry(mutexHandle, name);
97 vSemaphoreDelete(mutexHandle);
100 bool take(TickType_t wait = portMAX_DELAY)
override {
101 return xSemaphoreTake(mutexHandle, wait);
103#if FREERTOSCPP_USE_CHRONO
104 bool take(Time_ms wait) {
105 return xSemaphoreTake(mutexHandle, ms2ticks(wait));
110 return xSemaphoreGive(mutexHandle);
114#if __cplusplus < 201101L
116 void operator =(
Mutex const&);
119 void operator =(
Mutex const&) =
delete;
121#if( configSUPPORT_STATIC_ALLOCATION == 1 )
122 StaticSemaphore_t mutexBuffer;
127#if configUSE_RECURSIVE_MUTEXES > 0
163#if( configSUPPORT_STATIC_ALLOCATION == 1 )
164 mutexHandle = xSemaphoreCreateRecursiveMutexStatic(&mutexBuffer);
166 mutexHandle = xSemaphoreCreateRecursiveMutex();
168#if configQUEUE_REGISTRY_SIZE > 0
170 vQueueAddToRegistry(mutexHandle, name);
174 vSemaphoreDelete(mutexHandle);
177 bool take(TickType_t wait = portMAX_DELAY)
override {
178 return xSemaphoreTakeRecursive(mutexHandle, wait);
181 return xSemaphoreGiveRecursive(mutexHandle);
186#if __cplusplus < 201101L
193#if( configSUPPORT_STATIC_ALLOCATION == 1 )
194 StaticSemaphore_t mutexBuffer;
199#if FREERTOSCPP_USE_NAMESPACE
A Base class to provide block based locking capability.
Definition Lock.h:58
Mutex Wrapper.
Definition MutexCPP.h:75
Mutex(char const *name)
Constructor.
Definition MutexCPP.h:81
bool take(TickType_t wait=portMAX_DELAY) override
Definition MutexCPP.h:100
~Mutex()
Destructor.
Definition MutexCPP.h:96
Mutex(Mutex const &)=delete
We are not copyable.
SemaphoreHandle_t mutexHandle
Definition MutexCPP.h:113
bool give() override
Definition MutexCPP.h:109
Recursive Mutex Wrapper.
Definition MutexCPP.h:160
RecursiveMutex(RecursiveMutex const &)=delete
We are not copyable.
bool take(TickType_t wait=portMAX_DELAY) override
Definition MutexCPP.h:177
~RecursiveMutex()
Definition MutexCPP.h:173
SemaphoreHandle_t mutexHandle
Definition MutexCPP.h:185
RecursiveMutex(char const *name=nullptr)
Definition MutexCPP.h:162
bool give() override
Definition MutexCPP.h:180
Definition FreeRTOScpp.h:74