tweaked factory to have configurability
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
#include <framework/osal/FreeRTOS/BinarySemaphore.h>
|
||||
#include <framework/osal/FreeRTOS/BinSemaphUsingTask.h>
|
||||
#include <framework/osal/FreeRTOS/CountingSemaphore.h>
|
||||
#include <framework/osal/FreeRTOS/CountingSemaphUsingTask.h>
|
||||
#include <framework/tasks/SemaphoreFactory.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
|
||||
@ -7,6 +9,9 @@ SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr;
|
||||
const uint32_t SemaphoreIF::NO_TIMEOUT = 0;
|
||||
const uint32_t SemaphoreIF::MAX_TIMEOUT = portMAX_DELAY;
|
||||
|
||||
static const uint32_t USE_REGULAR_SEMAPHORES = 0;
|
||||
static const uint32_t USE_TASK_NOTIFICATIONS = 1;
|
||||
|
||||
SemaphoreFactory::SemaphoreFactory() {
|
||||
}
|
||||
|
||||
@ -22,12 +27,33 @@ SemaphoreFactory* SemaphoreFactory::instance() {
|
||||
}
|
||||
|
||||
SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t argument) {
|
||||
return new BinarySemaphore();
|
||||
if(argument == USE_REGULAR_SEMAPHORES) {
|
||||
return new BinarySemaphore();
|
||||
}
|
||||
else if(argument == USE_TASK_NOTIFICATIONS) {
|
||||
return new BinarySemaphoreUsingTask();
|
||||
}
|
||||
else {
|
||||
sif::warning << "SemaphoreFactory: Invalid argument, return regular"
|
||||
"binary semaphore" << std::endl;
|
||||
return new BinarySemaphore();
|
||||
}
|
||||
}
|
||||
|
||||
SemaphoreIF* SemaphoreFactory::createCountingSemaphore(uint8_t count,
|
||||
uint8_t initCount, uint32_t argument) {
|
||||
return new CountingSemaphore(count, initCount);
|
||||
if(argument == USE_REGULAR_SEMAPHORES) {
|
||||
return new CountingSemaphore(count, initCount);
|
||||
}
|
||||
else if(argument == USE_TASK_NOTIFICATIONS) {
|
||||
return new CountingSemaphoreUsingTask(count, initCount);
|
||||
}
|
||||
else {
|
||||
sif::warning << "SemaphoreFactory: Invalid argument, return regular"
|
||||
"binary semaphore" << std::endl;
|
||||
return new CountingSemaphore(count, initCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SemaphoreFactory::deleteSemaphore(SemaphoreIF* semaphore) {
|
||||
|
Reference in New Issue
Block a user