Class template to manipulate a fixed-size memory pool.
More...
#include <fixed_mem_pool.h>
template<class _Tp>
class nvwa::fixed_mem_pool< _Tp >
Class template to manipulate a fixed-size memory pool.
Please notice that only allocate and deallocate are protected by a lock.
- Parameters
-
◆ allocate()
Allocates a memory block from the memory pool.
- Returns
- pointer to the allocated memory block
◆ bad_alloc_handler()
Bad allocation handler.
Called when there are no memory blocks available in the memory pool. If this function returns false
(default behaviour if not explicitly specialized), it indicates that it can do nothing and allocate() should return null; if this function returns true
, it indicates that it has freed some memory blocks and allocate() should try allocating again.
◆ deallocate()
Deallocates a memory block and returns it to the memory pool.
- Parameters
-
block_ptr | pointer to the memory block to return |
◆ deinitialize()
Deinitializes the memory pool.
- Returns
0
if all memory blocks are returned and the memory pool successfully freed; or a non-zero value indicating number of memory blocks still in allocation
◆ get_alloc_count()
Gets the allocation count.
- Returns
- the number of memory blocks still in allocation
◆ initialize()
Initializes the memory pool.
- Parameters
-
size | number of memory blocks to put in the memory pool |
- Returns
true
if successful; false
if memory insufficient
◆ is_initialized()
Is the memory pool initialized?
- Returns
true
if it is successfully initialized; false
otherwise
◆ _S_alloc_cnt
◆ _S_first_avail_ptr
Pointer to the first available memory block.
◆ _S_mem_pool_ptr
Pointer to the allocated chunk of memory.
The documentation for this class was generated from the following file: