fsfw/src/fsfw/osal/host/MutexFactory.cpp

28 lines
722 B
C++
Raw Normal View History

#include "fsfw/ipc/MutexFactory.h"
2020-09-05 20:18:52 +02:00
2022-02-02 10:29:30 +01:00
#include "fsfw/osal/host/Mutex.h"
// TODO: Different variant than the lazy loading in QueueFactory.
// What's better and why? -> one is on heap the other on bss/data
// MutexFactory* MutexFactory::factoryInstance = new MutexFactory();
2020-09-05 20:18:52 +02:00
MutexFactory* MutexFactory::factoryInstance = nullptr;
2022-02-02 10:29:30 +01:00
MutexFactory::MutexFactory() {}
2020-09-05 20:18:52 +02:00
2022-02-02 10:29:30 +01:00
MutexFactory::~MutexFactory() {}
2020-09-05 20:18:52 +02:00
MutexFactory* MutexFactory::instance() {
2022-02-02 10:29:30 +01:00
if (factoryInstance == nullptr) {
factoryInstance = new MutexFactory();
}
return MutexFactory::factoryInstance;
2020-09-05 20:18:52 +02:00
}
2022-02-02 10:29:30 +01:00
MutexIF* MutexFactory::createMutex() { return new Mutex(); }
2020-09-05 20:18:52 +02:00
void MutexFactory::deleteMutex(MutexIF* mutex) {
2022-02-02 10:29:30 +01:00
if (mutex != nullptr) {
delete mutex;
}
2020-09-05 20:18:52 +02:00
}