#include <oldpool.h>
Inherited by OldMemoryPool< T >.
Public Member Functions | |
void | CleanPool () |
Clean a pool in a safe way (does free all blocks). | |
bool | AddBlockToPool () |
This function tries to increase the size of array by adding 1 block too it. | |
bool | AddBlockIfNeeded (uint index) |
Adds blocks to the pool if needed (and possible) till index fits inside the pool. | |
void | UpdateFirstFreeIndex (uint index) |
Check if the index of pool item being deleted is lower than cached first_free_index. | |
uint | GetSize () const |
Get the size of this pool, i.e. | |
bool | CanAllocateMoreBlocks () const |
Can this pool allocate more blocks, i.e. | |
uint | GetBlockCount () const |
Get the maximum number of allocable blocks. | |
const char * | GetName () const |
Get the name of this pool. | |
bool | CleaningPool () const |
Is the pool in the cleaning phase? | |
Data Fields | |
const uint | item_size |
How many bytes one block is. | |
uint | first_free_index |
The index of the first free pool item in this pool. | |
byte ** | blocks |
An array of blocks (one block hold all the items). | |
Protected Member Functions | |
OldMemoryPoolBase (const char *name, uint max_blocks, uint block_size_bits, uint item_size, OldMemoryPoolNewBlock *new_block_proc, OldMemoryPoolCleanBlock *clean_block_proc) | |
Protected Attributes | |
const char * | name |
Name of the pool (just for debugging). | |
const uint | max_blocks |
The max amount of blocks this pool can have. | |
const uint | block_size_bits |
The size of each block in bits. | |
OldMemoryPoolNewBlock * | new_block_proc |
Pointer to a function that is called after a new block is added. | |
OldMemoryPoolCleanBlock * | clean_block_proc |
Pointer to a function that is called to clean a block. | |
uint | current_blocks |
How many blocks we have in our pool. | |
uint | total_items |
How many items we now have in this pool. | |
bool | cleaning_pool |
Are we currently cleaning the pool? |
Use the wrappers to access the OldMemoryPool please try to avoid manual calls!
Definition at line 20 of file oldpool.h.
bool OldMemoryPoolBase::AddBlockToPool | ( | ) |
This function tries to increase the size of array by adding 1 block too it.
Definition at line 46 of file oldpool.cpp.
References block_size_bits, blocks, current_blocks, item_size, max_blocks, name, new_block_proc, ReallocT(), and total_items.
Referenced by AddBlockIfNeeded().
bool OldMemoryPoolBase::AddBlockIfNeeded | ( | uint | index | ) |
Adds blocks to the pool if needed (and possible) till index fits inside the pool.
Definition at line 78 of file oldpool.cpp.
References AddBlockToPool(), and total_items.
void OldMemoryPoolBase::UpdateFirstFreeIndex | ( | uint | index | ) | [inline] |
Check if the index of pool item being deleted is lower than cached first_free_index.
index | index of pool item |
Definition at line 56 of file oldpool.h.
References first_free_index, and min().
uint OldMemoryPoolBase::GetSize | ( | ) | const [inline] |
Get the size of this pool, i.e.
the total number of items you can put into it at the current moment; the pool might still be able to increase the size of the pool.
Definition at line 67 of file oldpool.h.
References total_items.
bool OldMemoryPoolBase::CanAllocateMoreBlocks | ( | ) | const [inline] |
Can this pool allocate more blocks, i.e.
is the maximum amount of allocated blocks not yet reached?
Definition at line 78 of file oldpool.h.
References current_blocks.
uint OldMemoryPoolBase::GetBlockCount | ( | ) | const [inline] |
Get the maximum number of allocable blocks.
Definition at line 87 of file oldpool.h.
References current_blocks.
const char* OldMemoryPoolBase::GetName | ( | ) | const [inline] |
bool OldMemoryPoolBase::CleaningPool | ( | ) | const [inline] |
Is the pool in the cleaning phase?
Definition at line 105 of file oldpool.h.
References cleaning_pool.