2020-09-29 14:49:57 +02:00
|
|
|
#ifndef FSFW_STORAGEMANAGER_POOLMANAGER_H_
|
|
|
|
#define FSFW_STORAGEMANAGER_POOLMANAGER_H_
|
2020-08-28 18:33:29 +02:00
|
|
|
|
2020-09-29 14:49:57 +02:00
|
|
|
#include "LocalPool.h"
|
|
|
|
#include "StorageAccessor.h"
|
2020-08-28 18:33:29 +02:00
|
|
|
#include "../ipc/MutexHelper.h"
|
2020-09-29 14:49:57 +02:00
|
|
|
|
2020-08-28 18:33:29 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The PoolManager class provides an intermediate data storage with
|
|
|
|
* a fixed pool size policy for inter-process communication.
|
|
|
|
* @details Uses local pool calls but is thread safe by protecting the call
|
|
|
|
* with a lock.
|
|
|
|
* @author Bastian Baetz
|
|
|
|
*/
|
2020-10-14 23:20:53 +02:00
|
|
|
class PoolManager: public LocalPool {
|
2020-08-28 18:33:29 +02:00
|
|
|
public:
|
2020-10-14 23:20:53 +02:00
|
|
|
PoolManager(object_id_t setObjectId, const LocalPoolConfig poolConfig);
|
2020-08-28 18:33:29 +02:00
|
|
|
|
2020-09-29 14:49:57 +02:00
|
|
|
/**
|
|
|
|
* @brief In the PoolManager's destructor all allocated memory
|
|
|
|
* is freed.
|
|
|
|
*/
|
2020-08-28 18:33:29 +02:00
|
|
|
virtual ~PoolManager();
|
|
|
|
|
2020-09-29 14:49:57 +02:00
|
|
|
/**
|
|
|
|
* @brief LocalPool overrides for thread-safety. Decorator function
|
|
|
|
* which wraps LocalPool calls with a mutex protection.
|
|
|
|
*/
|
2020-08-28 18:33:29 +02:00
|
|
|
ReturnValue_t deleteData(store_address_t) override;
|
|
|
|
ReturnValue_t deleteData(uint8_t* buffer, size_t size,
|
|
|
|
store_address_t* storeId = nullptr) override;
|
|
|
|
|
2020-09-29 14:49:57 +02:00
|
|
|
void setMutexTimeout(uint32_t mutexTimeoutMs);
|
2020-08-28 18:33:29 +02:00
|
|
|
protected:
|
|
|
|
//! Default mutex timeout value to prevent permanent blocking.
|
2020-09-29 14:49:57 +02:00
|
|
|
uint32_t mutexTimeoutMs = 20;
|
2020-08-28 18:33:29 +02:00
|
|
|
|
2020-10-14 23:20:53 +02:00
|
|
|
ReturnValue_t reserveSpace(const size_t size, store_address_t* address,
|
2020-08-28 18:33:29 +02:00
|
|
|
bool ignoreFault) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The mutex is created in the constructor and makes
|
|
|
|
* access mutual exclusive.
|
|
|
|
* @details Locking and unlocking is done during searching for free slots
|
|
|
|
* and deleting existing slots.
|
|
|
|
*/
|
|
|
|
MutexIF* mutex;
|
|
|
|
};
|
|
|
|
|
2020-09-29 14:49:57 +02:00
|
|
|
#endif /* FSFW_STORAGEMANAGER_POOLMANAGER_H_ */
|