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>
|
|
|
|
|
|
|
|
const uint32_t SemaphoreIF::NO_TIMEOUT = 0;
|
2020-05-27 11:48:11 +02:00
|
|
|
const uint32_t SemaphoreIF::MAX_TIMEOUT = 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;
|
|
|
|
}
|