mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-06-10 01:55:59 +00:00
Added mutex timeout and mutex ownership
This commit is contained in:
parent
4ce4653f71
commit
33a1f757a2
@ -9,6 +9,7 @@
|
||||
|
||||
#include <cmsis_os2.h>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
@ -30,10 +31,17 @@ namespace sta
|
||||
*/
|
||||
RtosMutex(const char* name);
|
||||
|
||||
/**
|
||||
* @brief Method for checking mutex ownership.
|
||||
*
|
||||
* @return Returns true if the currently running thread is the owner of the mutex.
|
||||
*/
|
||||
bool isCurrentThreadOwner() override;
|
||||
|
||||
/**
|
||||
* @brief Acquire the mutex.
|
||||
*/
|
||||
void acquire() override;
|
||||
void acquire(uint32_t timeout = osWaitForever) override;
|
||||
|
||||
/**
|
||||
* @brief Release the mutex.
|
||||
|
@ -17,9 +17,17 @@ namespace sta
|
||||
STA_ASSERT(handle_ != NULL);
|
||||
}
|
||||
|
||||
void RtosMutex::acquire()
|
||||
bool RtosMutex::isCurrentThreadOwner()
|
||||
{
|
||||
osMutexAcquire(handle_, osWaitForever);
|
||||
osThreadId_t id = osThreadGetId();
|
||||
STA_ASSERT_MSG(id != NULL, "Failed to get current thread id.");
|
||||
|
||||
return osMutexGetOwner(handle_) == id;
|
||||
}
|
||||
|
||||
void RtosMutex::acquire(uint32_t timeout /* = osWaitForever */)
|
||||
{
|
||||
osMutexAcquire(handle_, timeout);
|
||||
}
|
||||
|
||||
void RtosMutex::release()
|
||||
|
Loading…
x
Reference in New Issue
Block a user