|
Click
|
#include <allocator.hh>
Inherits pool_allocator_mt_base.
Public Types | |
| typedef struct pool_allocator_mt::item_t | item |
| typedef struct pool_allocator_mt::Pool_t | Pool |
| typedef struct pool_allocator_mt::GlobalPool_t | GlobalPool |
Public Member Functions | |
| void | static_initialize () |
| T * | allocate_uninitialized () |
| T * | allocate (const T &t) |
| T * | allocate () |
| void | release_unitialized (T *e) |
| void | release (T *e) |
Multithread-safe pool allocator.
There is one pool per thread, which can contains up to POOL_SIZE (default 64) objects.
If this pool is full, it will be moved to a global list (protected by a lock). The global list will contain at most POOL_COUNT pools.
If the global list limit is reached, the objects will be directly released.
Works mostly like the Click packet allocator.
This version use casting and reuses the memory from the items themselves to build linked list of pool. Use pool_allocator_aware_mt with virtual classes to avoid overwriting vtable pointer, by exposing a pool_next_item and pool_next_pool void* pointer to use instead of cast.
Template arguments :