fsfw/osal/FreeRTOS/SemaphoreFactory.cpp

36 lines
987 B
C++
Raw Normal View History

2020-05-18 20:35:13 +02:00
#include <framework/osal/FreeRTOS/BinarySemaphore.h>
#include <framework/osal/FreeRTOS/CountingSemaphore.h>
#include <framework/tasks/SemaphoreFactory.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr;
2020-05-27 11:48:11 +02:00
const uint32_t SemaphoreIF::NO_TIMEOUT = 0;
const uint32_t SemaphoreIF::MAX_TIMEOUT = portMAX_DELAY;
2020-05-18 20:35:13 +02:00
SemaphoreFactory::SemaphoreFactory() {
}
SemaphoreFactory::~SemaphoreFactory() {
delete factoryInstance;
}
SemaphoreFactory* SemaphoreFactory::instance() {
if (factoryInstance == nullptr){
factoryInstance = new SemaphoreFactory();
}
return SemaphoreFactory::factoryInstance;
}
SemaphoreIF* SemaphoreFactory::createBinarySemaphore() {
2020-05-18 20:39:48 +02:00
return new BinarySemaphore();
2020-05-18 20:35:13 +02:00
}
SemaphoreIF* SemaphoreFactory::createCountingSemaphore(uint8_t count,
uint8_t initCount) {
return new CountingSemaphore(count, initCount);
}
void SemaphoreFactory::deleteMutex(SemaphoreIF* semaphore) {
delete semaphore;
}