firmware/src/concurrency/Lock.cpp
2021-06-27 10:56:28 -07:00

34 lines
461 B
C++

#include "configuration.h"
#include "Lock.h"
#include <cassert>
namespace concurrency
{
#ifdef HAS_FREE_RTOS
Lock::Lock()
{
handle = xSemaphoreCreateBinary();
assert(handle);
assert(xSemaphoreGive(handle));
}
void Lock::lock()
{
assert(xSemaphoreTake(handle, portMAX_DELAY));
}
void Lock::unlock()
{
assert(xSemaphoreGive(handle));
}
#else
Lock::Lock() {}
void Lock::lock() {}
void Lock::unlock() {}
#endif
} // namespace concurrency