implemented semaph factory
This commit is contained in:
26
osal/FreeRTOS/CountingSemaphore.cpp
Normal file
26
osal/FreeRTOS/CountingSemaphore.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <framework/osal/FreeRTOS/CountingSemaphore.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
|
||||
CountingSemaphore::CountingSemaphore(uint8_t count, uint8_t initCount):
|
||||
count(count), initCount(initCount) {
|
||||
handle = xSemaphoreCreateCounting(count, initCount);
|
||||
if(handle == nullptr) {
|
||||
sif::error << "CountingSemaphore: Creation failure" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
CountingSemaphore::CountingSemaphore(CountingSemaphore&& other) {
|
||||
handle = xSemaphoreCreateCounting(other.count, other.initCount);
|
||||
if(handle == nullptr) {
|
||||
sif::error << "CountingSemaphore: Creation failure" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
CountingSemaphore& CountingSemaphore::operator =(
|
||||
CountingSemaphore&& other) {
|
||||
handle = xSemaphoreCreateCounting(other.count, other.initCount);
|
||||
if(handle == nullptr) {
|
||||
sif::error << "CountingSemaphore: Creation failure" << std::endl;
|
||||
}
|
||||
return * this;
|
||||
}
|
Reference in New Issue
Block a user