fsfw/osal/linux/SemaphoreFactory.cpp

37 lines
1.0 KiB
C++
Raw Normal View History

2020-05-27 00:28:13 +02:00
#include <framework/tasks/SemaphoreFactory.h>
2020-05-29 00:50:44 +02:00
#include <framework/osal/linux/BinarySemaphore.h>
2020-05-29 01:41:16 +02:00
#include <framework/osal/linux/CountingSemaphore.h>
2020-05-27 00:28:13 +02:00
#include <framework/serviceinterface/ServiceInterfaceStream.h>
2020-06-02 22:25:28 +02:00
const uint32_t SemaphoreIF::POLLING = 0;
const uint32_t SemaphoreIF::BLOCKING = 0xffffffff;
2020-05-27 00:28:13 +02:00
SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr;
SemaphoreFactory::SemaphoreFactory() {
}
SemaphoreFactory::~SemaphoreFactory() {
delete factoryInstance;
}
SemaphoreFactory* SemaphoreFactory::instance() {
if (factoryInstance == nullptr){
factoryInstance = new SemaphoreFactory();
}
return SemaphoreFactory::factoryInstance;
}
2020-05-29 00:47:54 +02:00
SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t arguments) {
2020-05-29 00:50:44 +02:00
return new BinarySemaphore();
2020-05-27 00:28:13 +02:00
}
2020-05-29 01:41:16 +02:00
SemaphoreIF* SemaphoreFactory::createCountingSemaphore(const uint8_t maxCount,
2020-05-29 00:47:54 +02:00
uint8_t initCount, uint32_t arguments) {
2020-05-29 01:41:16 +02:00
return new CountingSemaphore(maxCount, initCount);
2020-05-27 00:28:13 +02:00
}
2020-05-29 00:47:54 +02:00
void SemaphoreFactory::deleteSemaphore(SemaphoreIF* semaphore) {
2020-05-27 00:28:13 +02:00
delete semaphore;
}