From be4ac0bc8fa03faee1330a9899cb9051485eebba Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 27 May 2020 00:28:13 +0200 Subject: [PATCH] added semaph factory to linux --- osal/FreeRTOS/BinarySemaphore.cpp | 2 ++ osal/linux/SemaphoreFactory.cpp | 36 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 osal/linux/SemaphoreFactory.cpp diff --git a/osal/FreeRTOS/BinarySemaphore.cpp b/osal/FreeRTOS/BinarySemaphore.cpp index 026704d6..e6c308db 100644 --- a/osal/FreeRTOS/BinarySemaphore.cpp +++ b/osal/FreeRTOS/BinarySemaphore.cpp @@ -3,6 +3,8 @@ #include +const uint32_t SemaphoreIF::NO_TIMEOUT = 0; + BinarySemaphore::BinarySemaphore() { handle = xSemaphoreCreateBinary(); if(handle == nullptr) { diff --git a/osal/linux/SemaphoreFactory.cpp b/osal/linux/SemaphoreFactory.cpp new file mode 100644 index 00000000..7b80176b --- /dev/null +++ b/osal/linux/SemaphoreFactory.cpp @@ -0,0 +1,36 @@ +#include +#include + +const uint32_t SemaphoreIF::NO_TIMEOUT = 0; + +SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr; + +SemaphoreFactory::SemaphoreFactory() { +} + +SemaphoreFactory::~SemaphoreFactory() { + delete factoryInstance; +} + +SemaphoreFactory* SemaphoreFactory::instance() { + if (factoryInstance == nullptr){ + factoryInstance = new SemaphoreFactory(); + } + return SemaphoreFactory::factoryInstance; +} + +SemaphoreIF* SemaphoreFactory::createBinarySemaphore() { + sif::error << "Semaphore not implemented for Linux yet" << std::endl; + return nullptr; +} + +SemaphoreIF* SemaphoreFactory::createCountingSemaphore(uint8_t count, + uint8_t initCount) { + sif::error << "Counting Semaphore not implemented for " + "Linux yet" << std::endl; + return nullptr; +} + +void SemaphoreFactory::deleteMutex(SemaphoreIF* semaphore) { + delete semaphore; +}