Public Member Functions | Data Fields

ClassAllocator< C > Class Template Reference

Allocator for Class objects. More...

#include <Allocator.h>

Inherits Allocator.

Inherited by SparseClassAllocator< C >.

Collaboration diagram for ClassAllocator< C >:
Collaboration graph
[legend]

Public Member Functions

C * alloc ()
 Allocates objects of the templated type.
void free (C *ptr)
 Deallocates objects of the templated type.
void * alloc_void ()
 Allocate objects of the templated type via the inherited interface using void pointers.
void free_void (void *ptr)
 Deallocate objects of the templated type via the inherited interface using void pointers.
 ClassAllocator (const char *name, unsigned int chunk_size=128, unsigned int alignment=16)
 Create a new class specific ClassAllocator.

Data Fields

struct {
   C   typeObject
   int64_t   space_holder
proto

Detailed Description

template<class C>
class ClassAllocator< C >

Allocator for Class objects.

It uses a prototype object to do fast initialization. Prototype of the template class is created when the fast allocator is created. This is instantiated with default (no argument) constructor. Constructor is not called for the allocated objects. Instead, the prototype is just memory copied onto the new objects. This is done for performance reasons.

Definition at line 111 of file Allocator.h.


Constructor & Destructor Documentation

template<class C>
ClassAllocator< C >::ClassAllocator ( const char *  name,
unsigned int  chunk_size = 128,
unsigned int  alignment = 16 
) [inline]

Create a new class specific ClassAllocator.

Parameters:
name some identifying name, used for mem tracking purposes.
chunk_size number of units to be allocated if free pool is empty.
alignment of objects must be a power of 2.

Definition at line 163 of file Allocator.h.

References Allocator::fl, ink_freelist_init(), and RND16.


Member Function Documentation

template<class C>
C* ClassAllocator< C >::alloc (  )  [inline]
template<class C>
void* ClassAllocator< C >::alloc_void (  )  [inline]

Allocate objects of the templated type via the inherited interface using void pointers.

Reimplemented from Allocator.

Definition at line 139 of file Allocator.h.

References ClassAllocator< C >::alloc().

template<class C>
void ClassAllocator< C >::free ( C *  ptr  )  [inline]
template<class C>
void ClassAllocator< C >::free_void ( void *  ptr  )  [inline]

Deallocate objects of the templated type via the inherited interface using void pointers.

Parameters:
ptr pointer to be freed.

Reimplemented from Allocator.

Definition at line 151 of file Allocator.h.

References ClassAllocator< C >::free().


Field Documentation

struct { ... } ClassAllocator< C >::proto
template<class C>
int64_t ClassAllocator< C >::space_holder

Definition at line 172 of file Allocator.h.

template<class C>
C ClassAllocator< C >::typeObject

Definition at line 171 of file Allocator.h.

Referenced by thread_alloc(), and thread_alloc_init().


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