NEST
2.6.0,not_revisioned_source_dir@0
|
pool is a specialized allocator class for many identical small objects. More...
#include <allocator.h>
Classes | |
class | chunk |
struct | link |
Public Member Functions | |
pool () | |
Create pool for objects of size n. More... | |
pool (const pool &) | |
pool & | operator= (const pool &) |
pool (size_t n, size_t initial=100, size_t growth=1) | |
void | init (size_t n, size_t initial=100, size_t growth=1) |
~pool () | |
deallocate ALL memory More... | |
void | reserve_additional (size_t n) |
Increase the pools capacity (free slots) by n. More... | |
size_t | available (void) const |
void * | alloc (void) |
allocate one element More... | |
void | free (void *p) |
put element back into the pool More... | |
size_t | size_of (void) const |
size_t | get_el_size () const |
size_t | get_instantiations () const |
size_t | get_total () const |
Private Member Functions | |
void | grow (size_t) |
make pool larger by n elements More... | |
void | grow () |
make pool larger More... | |
Private Attributes | |
size_t | initial_block_size |
size_t | growth_factor |
size_t | block_size |
number of elements per chunk More... | |
size_t | el_size |
sizeof an element More... | |
size_t | instantiations |
number of instantiated elements More... | |
size_t | total |
total number of allocated elements More... | |
size_t | capacity |
number of free elements More... | |
chunk * | chunks |
linked list of memory chunks More... | |
link * | head |
head of free list More... | |
bool | initialized_ |
True if the pool is initialized. More... | |
pool is a specialized allocator class for many identical small objects.
It targets a performance close to the optimal performance which is achieved by allocating all needed objects at once.
sli::pool::pool | ( | ) |
Create pool for objects of size n.
Initial is the initial allocation block size, i.e. the number of objects per block. growth is the factor by which the allocations block increases after each growth.
sli::pool::pool | ( | const pool & | p | ) |
sli::pool::pool | ( | size_t | n, |
size_t | initial = 100 , |
||
size_t | growth = 1 |
||
) |
sli::pool::~pool | ( | ) |
deallocate ALL memory
References nest::names::n, sli::pool::chunk::next, and nest::names::p.
|
inline |
allocate one element
References block_size, grow(), growth_factor, head, instantiations, sli::pool::link::next, and nest::names::p.
Referenced by NumericDatum< D, slt >::operator new(), AggregateDatum< Name,&SLIInterpreter::Nametype >::operator new(), TrieDatum::operator new(), FunctionDatum::operator new(), and IteratorDatum::operator new().
|
inline |
References instantiations, and total.
|
inline |
put element back into the pool
References head, instantiations, sli::pool::link::next, and nest::names::p.
Referenced by NumericDatum< D, slt >::operator delete(), AggregateDatum< Name,&SLIInterpreter::Nametype >::operator delete(), TrieDatum::operator delete(), FunctionDatum::operator delete(), and IteratorDatum::operator delete().
|
inline |
References el_size.
|
inline |
References instantiations.
|
inline |
References total.
|
private |
make pool larger by n elements
References sli::pool::chunk::mem, nest::names::n, sli::pool::chunk::next, nest::names::p, and nest::names::start.
|
private |
make pool larger
Referenced by alloc().
void sli::pool::init | ( | size_t | n, |
size_t | initial = 100 , |
||
size_t | growth = 1 |
||
) |
References assert().
Referenced by nest::GenericModel< ElementT >::init_memory_().
References el_size, growth_factor, and initial_block_size.
void sli::pool::reserve_additional | ( | size_t | n | ) |
Increase the pools capacity (free slots) by n.
reserve_additional() ensures that the pool has at least n empty slots, i.e., that the pool can store at least n additional elements before more memory needs to be allocated from the operating system.
|
inline |
References el_size.
Referenced by NumericDatum< D, slt >::operator delete(), AggregateDatum< Name,&SLIInterpreter::Nametype >::operator delete(), TrieDatum::operator delete(), IteratorDatum::operator delete(), NumericDatum< D, slt >::operator new(), AggregateDatum< Name,&SLIInterpreter::Nametype >::operator new(), TrieDatum::operator new(), and IteratorDatum::operator new().
|
private |
number of elements per chunk
Referenced by alloc().
|
private |
number of free elements
|
private |
linked list of memory chunks
|
private |
sizeof an element
Referenced by get_el_size(), operator=(), and size_of().
|
private |
Referenced by alloc(), and operator=().
|
private |
Referenced by operator=().
|
private |
True if the pool is initialized.
|
private |
number of instantiated elements
Referenced by alloc(), available(), free(), and get_instantiations().
|
private |
total number of allocated elements
Referenced by available(), and get_total().