2022-02-02 10:29:30 +01:00
|
|
|
#include "fsfw/tasks/SemaphoreFactory.h"
|
|
|
|
|
2021-07-13 20:58:45 +02:00
|
|
|
#include "fsfw/osal/linux/BinarySemaphore.h"
|
|
|
|
#include "fsfw/osal/linux/CountingSemaphore.h"
|
2020-12-14 21:46:33 +01:00
|
|
|
|
2020-09-18 13:15:14 +02:00
|
|
|
SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr;
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
SemaphoreFactory::SemaphoreFactory() {}
|
2020-09-18 13:15:14 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
SemaphoreFactory::~SemaphoreFactory() { delete factoryInstance; }
|
2020-09-18 13:15:14 +02:00
|
|
|
|
|
|
|
SemaphoreFactory* SemaphoreFactory::instance() {
|
2022-02-02 10:29:30 +01:00
|
|
|
if (factoryInstance == nullptr) {
|
|
|
|
factoryInstance = new SemaphoreFactory();
|
|
|
|
}
|
|
|
|
return SemaphoreFactory::factoryInstance;
|
2020-09-18 13:15:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t arguments) {
|
2022-02-02 10:29:30 +01:00
|
|
|
return new BinarySemaphore();
|
2020-09-18 13:15:14 +02:00
|
|
|
}
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
SemaphoreIF* SemaphoreFactory::createCountingSemaphore(const uint8_t maxCount, uint8_t initCount,
|
|
|
|
uint32_t arguments) {
|
|
|
|
return new CountingSemaphore(maxCount, initCount);
|
2020-09-18 13:15:14 +02:00
|
|
|
}
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
void SemaphoreFactory::deleteSemaphore(SemaphoreIF* semaphore) { delete semaphore; }
|