Retry lock when failed and portMAX_DELAY

This commit is contained in:
2021-06-17 14:37:13 +02:00
parent e46e0dd33b
commit a504262f39

View File

@ -16,7 +16,12 @@ public:
LockHelper(SemaphoreHandle_t xMutex, TickType_t xTicksToWait = portMAX_DELAY) : LockHelper(SemaphoreHandle_t xMutex, TickType_t xTicksToWait = portMAX_DELAY) :
m_xMutex{xMutex}, m_xMutex{xMutex},
m_locked{xSemaphoreTake(m_xMutex, xTicksToWait) == pdPASS} m_locked{xSemaphoreTake(m_xMutex, xTicksToWait) == pdPASS}
{} {
if (m_xMutex &&
xTicksToWait == portMAX_DELAY &&
!m_locked)
while (!lock(xTicksToWait));
}
~LockHelper() ~LockHelper()
{ {