some minor improvements
This commit is contained in:
parent
446e7d2f82
commit
2ecd7c4493
@ -35,7 +35,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief This is the default constructor for a pool manager instance.
|
* @brief This is the default constructor for a pool manager instance.
|
||||||
* @details By passing two arrays of size NUMBER_OF_POOLS, the constructor
|
* @details By passing two arrays of size NUMBER_OF_POOLS, the constructor
|
||||||
* allocates memory (with \c new) for store and size_list. These
|
* allocates memory (with @c new) for store and size_list. These
|
||||||
* regions are all set to zero on start up.
|
* regions are all set to zero on start up.
|
||||||
* @param setObjectId The object identifier to be set. This allows for
|
* @param setObjectId The object identifier to be set. This allows for
|
||||||
* multiple instances of LocalPool in the system.
|
* multiple instances of LocalPool in the system.
|
||||||
@ -87,7 +87,7 @@ public:
|
|||||||
ReturnValue_t initialize() override;
|
ReturnValue_t initialize() override;
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* With this helper method, a free element of \c size is reserved.
|
* With this helper method, a free element of @c size is reserved.
|
||||||
* @param size The minimum packet size that shall be reserved.
|
* @param size The minimum packet size that shall be reserved.
|
||||||
* @param[out] address Storage ID of the reserved data.
|
* @param[out] address Storage ID of the reserved data.
|
||||||
* @return - #RETURN_OK on success,
|
* @return - #RETURN_OK on success,
|
||||||
@ -100,7 +100,8 @@ protected:
|
|||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Indicates that this element is free.
|
* Indicates that this element is free.
|
||||||
* This value limits the maximum size of a pool. Change to larger data type if increase is required.
|
* This value limits the maximum size of a pool. Change to larger data type
|
||||||
|
* if increase is required.
|
||||||
*/
|
*/
|
||||||
static const uint32_t STORAGE_FREE = 0xFFFFFFFF;
|
static const uint32_t STORAGE_FREE = 0xFFFFFFFF;
|
||||||
/**
|
/**
|
||||||
@ -126,7 +127,9 @@ private:
|
|||||||
* is also dynamically allocated there.
|
* is also dynamically allocated there.
|
||||||
*/
|
*/
|
||||||
uint32_t* size_list[NUMBER_OF_POOLS];
|
uint32_t* size_list[NUMBER_OF_POOLS];
|
||||||
bool spillsToHigherPools; //!< A variable to determine whether higher n pools are used if the store is full.
|
//! A variable to determine whether higher n pools are used if
|
||||||
|
//! the store is full.
|
||||||
|
bool spillsToHigherPools;
|
||||||
/**
|
/**
|
||||||
* @brief This method safely stores the given data in the given packet_id.
|
* @brief This method safely stores the given data in the given packet_id.
|
||||||
* @details It also sets the size in size_list. The method does not perform
|
* @details It also sets the size in size_list. The method does not perform
|
||||||
|
@ -29,6 +29,9 @@ public:
|
|||||||
store_address_t* storeId = nullptr) override;
|
store_address_t* storeId = nullptr) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
//! Default mutex timeout value to prevent permanent blocking.
|
||||||
|
static constexpr uint32_t mutexTimeout = 50;
|
||||||
|
|
||||||
ReturnValue_t reserveSpace(const uint32_t size, store_address_t* address,
|
ReturnValue_t reserveSpace(const uint32_t size, store_address_t* address,
|
||||||
bool ignoreFault) override;
|
bool ignoreFault) override;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ inline PoolManager<NUMBER_OF_POOLS>::~PoolManager(void) {
|
|||||||
template<uint8_t NUMBER_OF_POOLS>
|
template<uint8_t NUMBER_OF_POOLS>
|
||||||
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::reserveSpace(
|
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::reserveSpace(
|
||||||
const uint32_t size, store_address_t* address, bool ignoreFault) {
|
const uint32_t size, store_address_t* address, bool ignoreFault) {
|
||||||
MutexHelper mutexHelper(mutex,MutexIF::BLOCKING);
|
MutexHelper mutexHelper(mutex, mutexTimeout);
|
||||||
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::reserveSpace(size,
|
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::reserveSpace(size,
|
||||||
address,ignoreFault);
|
address,ignoreFault);
|
||||||
return status;
|
return status;
|
||||||
@ -33,7 +33,7 @@ inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(
|
|||||||
// debug << "PoolManager( " << translateObject(getObjectId()) <<
|
// debug << "PoolManager( " << translateObject(getObjectId()) <<
|
||||||
// " )::deleteData from store " << packet_id.pool_index <<
|
// " )::deleteData from store " << packet_id.pool_index <<
|
||||||
// ". id is "<< packet_id.packet_index << std::endl;
|
// ". id is "<< packet_id.packet_index << std::endl;
|
||||||
MutexHelper mutexHelper(mutex,MutexIF::BLOCKING);
|
MutexHelper mutexHelper(mutex, mutexTimeout);
|
||||||
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::deleteData(packet_id);
|
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::deleteData(packet_id);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(
|
|||||||
template<uint8_t NUMBER_OF_POOLS>
|
template<uint8_t NUMBER_OF_POOLS>
|
||||||
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(uint8_t* buffer,
|
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(uint8_t* buffer,
|
||||||
size_t size, store_address_t* storeId) {
|
size_t size, store_address_t* storeId) {
|
||||||
MutexHelper mutexHelper(mutex,MutexIF::BLOCKING);
|
MutexHelper mutexHelper(mutex, mutexTimeout);
|
||||||
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::deleteData(buffer,
|
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::deleteData(buffer,
|
||||||
size, storeId);
|
size, storeId);
|
||||||
return status;
|
return status;
|
||||||
|
Loading…
Reference in New Issue
Block a user