Merge remote-tracking branch 'upstream/mueller/master' into development

This commit is contained in:
Robin Müller 2021-02-06 16:14:29 +01:00
commit 939fa16d1a
4 changed files with 44 additions and 7 deletions

View File

@ -1,5 +1,6 @@
#include "PoolDataSetBase.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include <cstring>
PoolDataSetBase::PoolDataSetBase(PoolVariableIF** registeredVariablesArray,
const size_t maxFillCount):
@ -228,3 +229,20 @@ void PoolDataSetBase::setReadCommitProtectionBehaviour(
this->timeoutTypeForSingleVars = timeoutType;
this->mutexTimeoutForSingleVars = mutexTimeout;
}
/* We really should supply the container as a template argument instead of writing sth like this */
//PoolDataSetBase::PoolDataSetBase(const PoolDataSetBase &otherSet):
// fillCount(otherSet.fillCount), state(otherSet.state),
// maxFillCount(otherSet.maxFillCount),
// protectEveryReadCommitCall(otherSet.protectEveryReadCommitCall),
// timeoutTypeForSingleVars(otherSet.timeoutTypeForSingleVars),
// mutexTimeoutForSingleVars(otherSet.mutexTimeoutForSingleVars) {
// if(registeredVariables != nullptr and otherSet.registeredVariables != nullptr) {
// std::memcpy(reinterpret_cast<void*>(*(this->registeredVariables)),
// reinterpret_cast<const void*>(*(otherSet.registeredVariables)),
// fillCount * sizeof(PoolVariableIF*));
// }
//}
//
//const PoolDataSetBase& PoolDataSetBase::operator=(const PoolDataSetBase &otherSet) {
//}

View File

@ -39,8 +39,12 @@ public:
* supply a pointer to this dataset to PoolVariable
* initializations to register pool variables.
*/
PoolDataSetBase(PoolVariableIF** registeredVariablesArray,
const size_t maxFillCount);
PoolDataSetBase(PoolVariableIF** registeredVariablesArray, const size_t maxFillCount);
/* Forbidden for now */
PoolDataSetBase(const PoolDataSetBase& otherSet) = delete;
const PoolDataSetBase& operator=(const PoolDataSetBase& otherSet) = delete;
virtual~ PoolDataSetBase();
/**
@ -63,8 +67,7 @@ public:
* - @c SET_WAS_ALREADY_READ if read() is called twice without calling
* commit() in between
*/
virtual ReturnValue_t read(
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
virtual ReturnValue_t read(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t lockTimeout = 20) override;
/**
* @brief The commit call initializes writing back the registered variables.
@ -84,8 +87,7 @@ public:
* - @c COMMITING_WITHOUT_READING if set was not read yet and
* contains non write-only variables
*/
virtual ReturnValue_t commit(
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
virtual ReturnValue_t commit(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t lockTimeout = 20) override;
/**

View File

@ -67,9 +67,19 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(
LocalPoolDataSetBase::~LocalPoolDataSetBase() {
/* We only delete objects which were created in the class constructor */
if(periodicHelper != nullptr) {
delete periodicHelper;
}
/* In case set was read but not comitted, we commit all variables with an invalid state */
if(state == States::STATE_SET_WAS_READ) {
for (uint16_t count = 0; count < fillCount; count++) {
if(registeredVariables[count] != nullptr) {
registeredVariables[count]->setValid(false);
registeredVariables[count]->commit(MutexIF::TimeoutType::WAITING, 20);
}
}
}
}
ReturnValue_t LocalPoolDataSetBase::lockDataPool(

View File

@ -103,6 +103,12 @@ public:
*/
~LocalPoolDataSetBase();
/* The copy constructor and assingment constructor are forbidden for now.
The use-cases are limited and the first step would be to implement them properly for the
base class */
LocalPoolDataSetBase(const LocalPoolDataSetBase& otherSet) = delete;
const LocalPoolDataSetBase& operator=(const LocalPoolDataSetBase& otherSet) = delete;
void setValidityBufferGeneration(bool withValidityBuffer);
sid_t getSid() const;
@ -153,6 +159,7 @@ public:
bool hasChanged() const override;
object_id_t getCreatorObjectId();
protected:
sid_t sid;
//! This mutex is used if the data is created by one object only.