The Mutex class is used to synchronize the execution of threads. More...
#include <Mutex.h>
Public Member Functions | |
| Mutex () | |
| Create and Initialize a Mutex object. More... | |
| Mutex (const char *name) | |
| Create and Initialize a Mutex object. More... | |
| osStatus | lock (void) |
| Wait until a Mutex becomes available. More... | |
| osStatus | lock (uint32_t millisec) |
| Wait until a Mutex becomes available. More... | |
| bool | trylock () |
| Try to lock the mutex, and return immediately. More... | |
| bool | trylock_for (uint32_t millisec) |
| Try to lock the mutex for a specified time. More... | |
| bool | trylock_until (uint64_t millisec) |
| Try to lock the mutex until specified time. More... | |
| osStatus | unlock () |
| Unlock the mutex that has previously been locked by the same thread. More... | |
| osThreadId | get_owner () |
| Get the owner the this mutex. More... | |
| ~Mutex () | |
| Mutex destructor. More... | |
The Mutex class is used to synchronize the execution of threads.
This is, for example, used to protect access to a shared resource.
| Mutex | ( | const char * | name | ) |
Create and Initialize a Mutex object.
| name | name to be used for this mutex. It has to stay allocated for the lifetime of the thread. |
| osThreadId get_owner | ( | ) |
Get the owner the this mutex.
| osStatus lock | ( | void | ) |
Wait until a Mutex becomes available.
| osStatus lock | ( | uint32_t | millisec | ) |
Wait until a Mutex becomes available.
| millisec | timeout value. |
| bool trylock | ( | ) |
Try to lock the mutex, and return immediately.
| bool trylock_for | ( | uint32_t | millisec | ) |
Try to lock the mutex for a specified time.
| millisec | timeout value. |
| bool trylock_until | ( | uint64_t | millisec | ) |
Try to lock the mutex until specified time.
| millisec | absolute timeout time, referenced to Kernel::get_ms_count() |
| osStatus unlock | ( | ) |
Unlock the mutex that has previously been locked by the same thread.