semaphore factory update

This commit is contained in:
Robin Müller 2020-08-27 17:14:49 +02:00
parent 3be253efd6
commit 0fedad6da0
2 changed files with 52 additions and 51 deletions

View File

@ -1,6 +1,6 @@
#include "../../tasks/SemaphoreFactory.h" #include "../../tasks/SemaphoreFactory.h"
#include "../../osal/linux/BinarySemaphore.h" #include "BinarySemaphore.h"
#include "../../osal/linux/CountingSemaphore.h" #include "CountingSemaphore.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr; SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr;

View File

@ -1,49 +1,50 @@
#ifndef FRAMEWORK_TASKS_SEMAPHOREFACTORY_H_ #ifndef FSFW_TASKS_SEMAPHOREFACTORY_H_
#define FRAMEWORK_TASKS_SEMAPHOREFACTORY_H_ #define FSFW_TASKS_SEMAPHOREFACTORY_H_
#include "../tasks/SemaphoreIF.h"
#include "../tasks/SemaphoreIF.h"
/**
* Creates Semaphore. /**
* This class is a "singleton" interface, i.e. it provides an * Creates Semaphore.
* interface, but also is the base class for a singleton. * This class is a "singleton" interface, i.e. it provides an
*/ * interface, but also is the base class for a singleton.
class SemaphoreFactory { */
public: class SemaphoreFactory {
virtual ~SemaphoreFactory(); public:
/** virtual ~SemaphoreFactory();
* Returns the single instance of SemaphoreFactory. /**
* The implementation of #instance is found in its subclasses. * Returns the single instance of SemaphoreFactory.
* Thus, we choose link-time variability of the instance. * The implementation of #instance is found in its subclasses.
*/ * Thus, we choose link-time variability of the instance.
static SemaphoreFactory* instance(); */
static SemaphoreFactory* instance();
/**
* Create a binary semaphore. /**
* Creator function for a binary semaphore which may only be acquired once * Create a binary semaphore.
* @param argument Can be used to pass implementation specific information. * Creator function for a binary semaphore which may only be acquired once
* @return Pointer to newly created semaphore class instance. * @param argument Can be used to pass implementation specific information.
*/ * @return Pointer to newly created semaphore class instance.
SemaphoreIF* createBinarySemaphore(uint32_t arguments = 0); */
/** SemaphoreIF* createBinarySemaphore(uint32_t arguments = 0);
* Create a counting semaphore. /**
* Creator functons for a counting semaphore which may be acquired multiple * Create a counting semaphore.
* times. * Creator functons for a counting semaphore which may be acquired multiple
* @param count Semaphore can be taken count times. * times.
* @param initCount Initial count value. * @param count Semaphore can be taken count times.
* @param argument Can be used to pass implementation specific information. * @param initCount Initial count value.
* @return * @param argument Can be used to pass implementation specific information.
*/ * @return
SemaphoreIF* createCountingSemaphore(const uint8_t maxCount, */
uint8_t initCount, uint32_t arguments = 0); SemaphoreIF* createCountingSemaphore(const uint8_t maxCount,
uint8_t initCount, uint32_t arguments = 0);
void deleteSemaphore(SemaphoreIF* semaphore);
void deleteSemaphore(SemaphoreIF* semaphore);
private:
/** private:
* External instantiation is not allowed. /**
*/ * External instantiation is not allowed.
SemaphoreFactory(); */
static SemaphoreFactory* factoryInstance; SemaphoreFactory();
}; static SemaphoreFactory* factoryInstance;
};
#endif /* FRAMEWORK_TASKS_SEMAPHOREFACTORY_H_ */
#endif /* FSFW_TASKS_SEMAPHOREFACTORY_H_ */