Click
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
pool_allocator_mt< T, zero, POOL_SIZE, POOL_COUNT > Class Template Reference

#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)
 

Detailed Description

template<typename T, bool zero = false, int POOL_SIZE = 64, int POOL_COUNT = 32>
class pool_allocator_mt< T, zero, POOL_SIZE, POOL_COUNT >

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 :


The documentation for this class was generated from the following file: