Base class that provides the recursive mutex interface to FreeRTOS::RecursiveMutex and FreeRTOS::StaticRecursiveMutex. This class exists to override the lock() and unlock() functions which require different underlying functions from what is used in FreeRTOS::MutexBase.
More...
#include <FreeRTOS/Mutex.hpp>
|
|
| RecursiveMutexBase (const RecursiveMutexBase &)=delete |
| |
|
RecursiveMutexBase & | operator= (const RecursiveMutexBase &)=delete |
| |
| bool | lock (const TickType_t ticksToWait=portMAX_DELAY) const |
| | Function that calls xSemaphoreTakeRecursive( SemaphoreHandle_t
xMutex, TickType_t xTicksToWait )
|
| |
| bool | unlock () const |
| | Function that calls xSemaphoreGiveRecursive( SemaphoreHandle_t
xSemaphore )
|
| |
|
| MutexBase (const MutexBase &)=delete |
| |
|
MutexBase & | operator= (const MutexBase &)=delete |
| |
| bool | isValid () const |
| | Function that checks if the underlying semaphore handle is not NULL. This should be used to ensure a semaphore has been created correctly.
|
| |
| bool | lock (const TickType_t ticksToWait=portMAX_DELAY) const |
| | Function that calls xSemaphoreTake( SemaphoreHandle_t
xSemaphore, TickType_t xTicksToWait )
|
| |
| bool | lockFromISR (bool &higherPriorityTaskWoken) const |
| | Function that calls xSemaphoreTakeFromISR ( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken )
|
| |
| bool | lockFromISR () const |
| | Function that calls xSemaphoreTakeFromISR ( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken )
|
| |
| bool | unlock () const |
| | Function that calls xSemaphoreGive( SemaphoreHandle_t xSemaphore
)
|
| |
|
|
static void * | operator new (size_t, void *) |
| |
|
static void * | operator new[] (size_t, void *) |
| |
|
static void * | operator new (size_t)=delete |
| |
|
static void * | operator new[] (size_t)=delete |
| |
|
static void * | operator new (size_t)=delete |
| |
|
static void * | operator new[] (size_t)=delete |
| |
|
static void * | operator new (size_t, void *ptr) |
| |
|
static void * | operator new[] (size_t, void *ptr) |
| |
|
|
class | RecursiveMutex |
| |
|
class | StaticRecursiveMutex |
| |
Base class that provides the recursive mutex interface to FreeRTOS::RecursiveMutex and FreeRTOS::StaticRecursiveMutex. This class exists to override the lock() and unlock() functions which require different underlying functions from what is used in FreeRTOS::MutexBase.
- Note
- This class is not intended to be instantiated by the user. Use FreeRTOS::RecursiveMutex or FreeRTOS::StaticRecursiveMutex.
◆ lock()
| bool FreeRTOS::RecursiveMutexBase::lock |
( |
const TickType_t |
ticksToWait = portMAX_DELAY | ) |
const |
|
inline |
Function that calls xSemaphoreTakeRecursive( SemaphoreHandle_t
xMutex, TickType_t xTicksToWait )
Mutex.hpp
- See also
- https://www.freertos.org/xSemaphoreTakeRecursive.html
- Parameters
-
| ticksToWait | The time in ticks to wait for the mutex to become available. The macro portTICK_PERIOD_MS can be used to convert this to a real time. A block time of zero can be used to poll the mutex. If the task already owns the mutex then take() will return immediately no matter what the value of ticksToWait. |
- Return values
-
| true | If the mutex was locked. |
| false | If ticksToWait expired without the mutex becoming available. |
Example Usage
#include <FreeRTOS/Mutex.hpp>
#include <FreeRTOS/Task.hpp>
public:
void taskFunction() final;
};
class MyOtherTask : public FreeRTOS::
Task {
public:
void taskFunction() final;
};
void MyTask::taskFunction() {
}
void MyOtherTask::taskFunction() {
if (mutex.isValid()) {
if (mutex.lock()) {
mutex.lock(10);
mutex.unlock();
mutex.unlock();
mutex.unlock();
} else {
}
}
}
bool lock(const TickType_t ticksToWait=portMAX_DELAY) const
Function that calls xSemaphoreTake( SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait )
Definition Mutex.hpp:99
Class that encapsulates the functionality of a FreeRTOS mutex.
Definition Mutex.hpp:417
Class that encapsulates the functionality of a FreeRTOS task.
Definition Task.hpp:1427
◆ unlock()
| bool FreeRTOS::RecursiveMutexBase::unlock |
( |
| ) |
const |
|
inline |
Function that calls xSemaphoreGiveRecursive( SemaphoreHandle_t
xSemaphore )
Mutex.hpp
- See also
- https://www.freertos.org/xSemaphoreGiveRecursive.html
A mutex used recursively can be locked repeatedly by the owner. The mutex doesn't become available again until the owner has called unlock() for each successful lock request. For example, if a task successfully locks the same mutex 5 times then the mutex will not be available to any other task until it has also unlocked the mutex back exactly five times.
- Returns
- true If the mutex was unlocked.
-
false Otherwise.
Example Usage
#include <FreeRTOS/Mutex.hpp>
#include <FreeRTOS/Task.hpp>
public:
void taskFunction() final;
};
class MyOtherTask : public FreeRTOS::
Task {
public:
void taskFunction() final;
};
void MyTask::taskFunction() {
}
void MyOtherTask::taskFunction() {
if (mutex.isValid()) {
if (mutex.lock()) {
mutex.lock(10);
mutex.unlock();
mutex.unlock();
mutex.unlock();
} else {
}
}
}
The documentation for this class was generated from the following file:
- /home/runner/work/FreeRTOS-Cpp/FreeRTOS-Cpp/FreeRTOS-Cpp/include/FreeRTOS/Mutex.hpp