mirror of
https://github.com/meshtastic/firmware.git
synced 2026-10-10 07:38:42 -04:00
* Refactor memory management in Syslog and StoreForwardModule * Implement destructor for Lock * Refactor RotaryEncoder and PacketHistory to use smart pointers for better memory management * CH341 should use unique_ptr for improved memory management * Fix checks in PH * Improve Syslog::vlogf to handle variable argument lists more safely * Fix initOk method to use nullptr for null pointer check
46 lines
614 B
C++
46 lines
614 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();
|
|
}
|
|
}
|
|
|
|
Lock::~Lock()
|
|
{
|
|
vSemaphoreDelete(handle);
|
|
}
|
|
|
|
void Lock::lock()
|
|
{
|
|
if (xSemaphoreTake(handle, portMAX_DELAY) == false) {
|
|
abort();
|
|
}
|
|
}
|
|
|
|
void Lock::unlock()
|
|
{
|
|
if (xSemaphoreGive(handle) == false) {
|
|
abort();
|
|
}
|
|
}
|
|
#else
|
|
Lock::Lock() {}
|
|
|
|
Lock::~Lock() {}
|
|
|
|
void Lock::lock() {}
|
|
|
|
void Lock::unlock() {}
|
|
#endif
|
|
|
|
} // namespace concurrency
|