2021-07-13 20:22:54 +02:00
|
|
|
#include "fsfw/datapoollocal/SharedLocalDataSet.h"
|
2020-10-01 12:05:24 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
SharedLocalDataSet::SharedLocalDataSet(object_id_t objectId, sid_t sid, const size_t maxSize)
|
|
|
|
: SystemObject(objectId), LocalPoolDataSetBase(sid, nullptr, maxSize), poolVarVector(maxSize) {
|
|
|
|
this->setContainer(poolVarVector.data());
|
|
|
|
datasetLock = MutexFactory::instance()->createMutex();
|
2020-10-01 12:05:24 +02:00
|
|
|
}
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
SharedLocalDataSet::SharedLocalDataSet(object_id_t objectId, HasLocalDataPoolIF *owner,
|
|
|
|
uint32_t setId, const size_t maxSize)
|
|
|
|
: SystemObject(objectId),
|
|
|
|
LocalPoolDataSetBase(owner, setId, nullptr, maxSize),
|
|
|
|
poolVarVector(maxSize) {
|
|
|
|
this->setContainer(poolVarVector.data());
|
|
|
|
datasetLock = MutexFactory::instance()->createMutex();
|
2021-03-10 23:16:47 +01:00
|
|
|
}
|
|
|
|
|
2021-03-11 00:18:17 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
return HasReturnvaluesIF::RETURN_FAILED;
|
2021-03-11 00:18:17 +01:00
|
|
|
}
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
SharedLocalDataSet::~SharedLocalDataSet() { MutexFactory::instance()->deleteMutex(datasetLock); }
|
2021-03-10 23:16:47 +01:00
|
|
|
|
2020-10-01 12:05:24 +02:00
|
|
|
ReturnValue_t SharedLocalDataSet::unlockDataset() {
|
2022-02-02 10:29:30 +01:00
|
|
|
if (datasetLock != nullptr) {
|
|
|
|
return datasetLock->unlockMutex();
|
|
|
|
}
|
|
|
|
return HasReturnvaluesIF::RETURN_FAILED;
|
2020-10-01 12:05:24 +02:00
|
|
|
}
|