fsfw/misc/archive/SharedLocalDataset.cpp

34 lines
1.3 KiB
C++
Raw Permalink Normal View History

#include "fsfw/datapool/SharedLocalDataset.h"
2020-10-01 12:05:24 +02:00
SharedLocalDataset::SharedLocalDataset(object_id_t objectId, structure_id_t sid, const size_t maxSize)
: SystemObject(objectId), SharedDatasetBase(sid, nullptr, maxSize), poolVarVector(maxSize) {
2022-02-02 10:29:30 +01:00
this->setContainer(poolVarVector.data());
datasetLock = MutexFactory::instance()->createMutex();
2020-10-01 12:05:24 +02:00
}
SharedLocalDataset::SharedLocalDataset(object_id_t objectId, localpool::SharedPool& sharedPool,
2022-02-02 10:29:30 +01:00
uint32_t setId, const size_t maxSize)
: SystemObject(objectId),
SharedDatasetBase(sharedPool, setId, nullptr, maxSize),
2022-02-02 10:29:30 +01:00
poolVarVector(maxSize) {
this->setContainer(poolVarVector.data());
datasetLock = MutexFactory::instance()->createMutex();
2021-03-10 23:16:47 +01:00
}
SharedLocalDataset::~SharedLocalDataset() { MutexFactory::instance()->deleteMutex(datasetLock); }
ReturnValue_t SharedLocalDataset::lockDataset(MutexIF::TimeoutType timeoutType,
2022-02-02 10:29:30 +01:00
dur_millis_t mutexTimeout) {
if (datasetLock != nullptr) {
return datasetLock->lockMutex(timeoutType, mutexTimeout);
}
2022-08-15 20:28:16 +02:00
return returnvalue::FAILED;
2021-03-11 00:18:17 +01:00
}
ReturnValue_t SharedLocalDataset::unlockDataset() {
2022-02-02 10:29:30 +01:00
if (datasetLock != nullptr) {
return datasetLock->unlockMutex();
}
2022-08-15 20:28:16 +02:00
return returnvalue::FAILED;
2020-10-01 12:05:24 +02:00
}