2021-06-27 17:56:28 +00:00
|
|
|
#include "configuration.h"
|
2020-07-05 21:11:40 +00:00
|
|
|
#include "Lock.h"
|
|
|
|
#include <cassert>
|
|
|
|
|
2020-09-04 22:03:22 +00:00
|
|
|
namespace concurrency
|
|
|
|
{
|
2020-07-05 21:11:40 +00:00
|
|
|
|
2020-09-04 22:03:22 +00:00
|
|
|
#ifdef HAS_FREE_RTOS
|
2020-07-05 21:11:40 +00:00
|
|
|
Lock::Lock()
|
|
|
|
{
|
|
|
|
handle = xSemaphoreCreateBinary();
|
|
|
|
assert(handle);
|
|
|
|
assert(xSemaphoreGive(handle));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Lock::lock()
|
|
|
|
{
|
|
|
|
assert(xSemaphoreTake(handle, portMAX_DELAY));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Lock::unlock()
|
|
|
|
{
|
|
|
|
assert(xSemaphoreGive(handle));
|
|
|
|
}
|
2020-09-04 22:03:22 +00:00
|
|
|
#else
|
|
|
|
Lock::Lock() {}
|
|
|
|
|
|
|
|
void Lock::lock() {}
|
|
|
|
|
|
|
|
void Lock::unlock() {}
|
|
|
|
#endif
|
2020-07-05 21:11:40 +00:00
|
|
|
|
|
|
|
} // namespace concurrency
|