fsfw/misc/archive/SharedLocalDataset.cpp
2024-11-06 16:55:09 +01:00

34 lines
1.3 KiB
C++

#include "fsfw/datapool/SharedLocalDataset.h"
SharedLocalDataset::SharedLocalDataset(object_id_t objectId, structure_id_t sid, const size_t maxSize)
: SystemObject(objectId), SharedDatasetBase(sid, nullptr, maxSize), poolVarVector(maxSize) {
this->setContainer(poolVarVector.data());
datasetLock = MutexFactory::instance()->createMutex();
}
SharedLocalDataset::SharedLocalDataset(object_id_t objectId, localpool::SharedPool& sharedPool,
uint32_t setId, const size_t maxSize)
: SystemObject(objectId),
SharedDatasetBase(sharedPool, setId, nullptr, maxSize),
poolVarVector(maxSize) {
this->setContainer(poolVarVector.data());
datasetLock = MutexFactory::instance()->createMutex();
}
SharedLocalDataset::~SharedLocalDataset() { MutexFactory::instance()->deleteMutex(datasetLock); }
ReturnValue_t SharedLocalDataset::lockDataset(MutexIF::TimeoutType timeoutType,
dur_millis_t mutexTimeout) {
if (datasetLock != nullptr) {
return datasetLock->lockMutex(timeoutType, mutexTimeout);
}
return returnvalue::FAILED;
}
ReturnValue_t SharedLocalDataset::unlockDataset() {
if (datasetLock != nullptr) {
return datasetLock->unlockMutex();
}
return returnvalue::FAILED;
}