mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-13 05:17:34 +00:00
35 lines
521 B
C++
35 lines
521 B
C++
#include "Lock.h"
|
|
#include "configuration.h"
|
|
#include <cassert>
|
|
|
|
namespace concurrency {
|
|
|
|
#ifdef HAS_FREE_RTOS
|
|
Lock::Lock() : handle(xSemaphoreCreateBinary()) {
|
|
assert(handle);
|
|
if (xSemaphoreGive(handle) == false) {
|
|
abort();
|
|
}
|
|
}
|
|
|
|
void Lock::lock() {
|
|
if (xSemaphoreTake(handle, portMAX_DELAY) == false) {
|
|
abort();
|
|
}
|
|
}
|
|
|
|
void Lock::unlock() {
|
|
if (xSemaphoreGive(handle) == false) {
|
|
abort();
|
|
}
|
|
}
|
|
#else
|
|
Lock::Lock() {}
|
|
|
|
void Lock::lock() {}
|
|
|
|
void Lock::unlock() {}
|
|
#endif
|
|
|
|
} // namespace concurrency
|