refactored threading-related classes, code broken

This commit is contained in:
grcasanova
2020-07-05 23:11:40 +02:00
parent 64da384fc1
commit 0a6059ba13
16 changed files with 243 additions and 245 deletions

23
src/concurrency/Lock.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include "Lock.h"
#include <cassert>
namespace concurrency {
Lock::Lock()
{
handle = xSemaphoreCreateBinary();
assert(handle);
assert(xSemaphoreGive(handle));
}
void Lock::lock()
{
assert(xSemaphoreTake(handle, portMAX_DELAY));
}
void Lock::unlock()
{
assert(xSemaphoreGive(handle));
}
} // namespace concurrency