mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-04 03:39:56 +00:00
33 lines
457 B
C++
33 lines
457 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
|