Base class for all pools. More...
#include <pool_type.hpp>
Data Structures | |
| struct | AllocCache |
| Helper struct to cache 'freed' PoolItems so we do not need to allocate them again. More... | |
| struct | PoolItem |
| Base class for all PoolItems. More... | |
Public Member Functions | |
| Pool (const char *name) | |
| void | CleanPool () |
| FORCEINLINE Titem * | Get (size_t index) |
| Returs Titem with given index. | |
| FORCEINLINE bool | IsValidID (size_t index) |
| Tests whether given index can be used to get valid (non-NULL) Titem. | |
| FORCEINLINE bool | CanAllocate (size_t n=1) |
| Tests whether we can allocate 'n' items. | |
Data Fields | |
| const char *const | name |
| Name of this pool. | |
| size_t | size |
| Current allocated size. | |
| size_t | first_free |
| No item with index lower than this is free (doesn't say anything about this one!). | |
| size_t | first_unused |
| This and all higher indexes are free (doesn't say anything about first_unused-1 !). | |
| size_t | items |
| Number of used indexes (non-NULL). | |
| bool | cleaning |
| True if cleaning pool (deleting all items). | |
| Titem ** | data |
| Pointer to array of pointers to Titem. | |
Static Public Attributes | |
| static const size_t | MAX_SIZE = Tmax_size |
| Make template parameter accessible from outside. | |
Private Member Functions | |
| void * | AllocateItem (size_t size, size_t index) |
| void | ResizeFor (size_t index) |
| size_t | FindFirstFree () |
| void * | GetNew (size_t size) |
| void * | GetNew (size_t size, size_t index) |
| void | FreeItem (size_t index) |
Private Attributes | |
| AllocCache * | alloc_cache |
| Cache of freed pointers. | |
Static Private Attributes | |
| static const size_t | NO_FREE_ITEM = MAX_UVALUE(size_t) |
| Contant to indicate we can't allocate any more items. | |
Base class for all pools.
| Titem | Type of the class/struct that is going to be pooled | |
| Tindex | Type of the index for this pool | |
| Tgrowth_step | Size of growths; if the pool is full increase the size by this amount | |
| Tmax_size | Maximum size of the pool | |
| Tcache | Whether to perform 'alloc' caching, i.e. don't actually free/malloc just reuse the memory | |
| Tzero | Whether to zero the memory |
Definition at line 26 of file pool_type.hpp.
| FORCEINLINE bool Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::CanAllocate | ( | size_t | n = 1 |
) | [inline] |
Tests whether we can allocate 'n' items.
| n | number of items we want to allocate |
Definition at line 69 of file pool_type.hpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::items.
| FORCEINLINE Titem* Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::Get | ( | size_t | index | ) | [inline] |
Returs Titem with given index.
| index | of item to get |
Definition at line 48 of file pool_type.hpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::data, and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::first_unused.
Referenced by Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::IsValidID().
| FORCEINLINE bool Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::IsValidID | ( | size_t | index | ) | [inline] |
Tests whether given index can be used to get valid (non-NULL) Titem.
| index | index to examine |
Definition at line 59 of file pool_type.hpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::first_unused, and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::Get().
1.7.1