fsfw/storagemanager/PoolManager.cpp

63 lines
1.7 KiB
C++
Raw Normal View History

2020-10-15 13:43:23 +02:00
#include "PoolManager.h"
2020-12-01 13:50:33 +01:00
#include <FSFWConfig.h>
2020-10-15 13:43:23 +02:00
PoolManager::PoolManager(object_id_t setObjectId,
const LocalPoolConfig& localPoolConfig):
LocalPool(setObjectId, localPoolConfig, true) {
mutex = MutexFactory::instance()->createMutex();
}
PoolManager::~PoolManager(void) {
MutexFactory::instance()->deleteMutex(mutex);
}
ReturnValue_t PoolManager::reserveSpace(const size_t size,
store_address_t* address, bool ignoreFault) {
MutexHelper mutexHelper(mutex, MutexIF::TimeoutType::WAITING,
mutexTimeoutMs);
ReturnValue_t status = LocalPool::reserveSpace(size,
address,ignoreFault);
return status;
}
ReturnValue_t PoolManager::deleteData(
store_address_t storeId) {
2020-12-01 13:50:33 +01:00
#if FSFW_VERBOSE_PRINTOUT == 2
2021-01-03 14:16:52 +01:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2020-10-15 13:43:23 +02:00
sif::debug << "PoolManager( " << translateObject(getObjectId()) <<
" )::deleteData from store " << storeId.poolIndex <<
". id is "<< storeId.packetIndex << std::endl;
#endif
2020-10-15 13:43:23 +02:00
#endif
MutexHelper mutexHelper(mutex, MutexIF::TimeoutType::WAITING,
mutexTimeoutMs);
return LocalPool::deleteData(storeId);
}
ReturnValue_t PoolManager::deleteData(uint8_t* buffer,
size_t size, store_address_t* storeId) {
MutexHelper mutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20);
ReturnValue_t status = LocalPool::deleteData(buffer,
size, storeId);
return status;
}
void PoolManager::setMutexTimeout(
uint32_t mutexTimeoutMs) {
this->mutexTimeoutMs = mutexTimeoutMs;
}
ReturnValue_t PoolManager::lockMutex(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
return mutex->lockMutex(timeoutType, timeoutMs);
}
ReturnValue_t PoolManager::unlockMutex() {
return mutex->unlockMutex();
}