AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agx::MemoryPool< T > Class Template Reference

Memory pool. More...

#include <MemoryPool.h>

+ Inheritance diagram for agx::MemoryPool< T >:

Public Member Functions

 MemoryPool (const char *name="MemoryPool", uint32_t initialChunkSize=64)
 Constructor. More...
 
virtual ~MemoryPool ()
 Destructor. More...
 
void * allocate (uint32_t numBytes)
 
void * allocate (uint32_t numBytes, uint32_t alignment)
 
T * allocate ()
 Allocates one element, no constructor called. More...
 
void * allocateBytes (size_t numBytes, size_t alignment=16)
 Allocate a memory section of specified alignment. More...
 
void clear ()
 Clears the memory pool and runs the destructor on every allocated object. More...
 
void clearFast ()
 Clears the memory pool without calling destructors. More...
 
T * create ()
 Allocates an element and calls its default constructor. More...
 
void deallocate (void *buffer)
 
void deallocate (T *element)
 Deallocates one element, no destructor called. More...
 
void deallocateBytes (void *buffer, size_t numBytes)
 Deallocate a section previously allocated using allocateBytes method. More...
 
void deallocateBytes (void *buffer)
 
virtual void deallocateVirtual (void *ptr)
 
void destroy (T *element)
 Deallocates an element and calls its destructor. More...
 
const char * getName () const
 
void setContainer (class Container *)
 
size_t size ()
 
size_t size () const
 

Static Public Member Functions

static void initMemory (void *data, size_t numBytes, agx::UInt32 pattern)
 
static void * standaloneAllocateBytes (size_t numBytes, size_t alignment=16)
 
static void standaloneDeallocateTypes (void *buffer)
 

Static Public Attributes

static agx::UInt32 allocatedMemoryPattern
 
static agx::UInt32 deallocatedMemoryPattern
 
static bool initMemoryFlag
 

Protected Member Functions

void createChunk (uint32_t size)
 
size_t deleteAllChunks ()
 

Protected Attributes

uint32_t m_chunkSize
 
Chunk * m_firstChunk
 

Detailed Description

template<typename T>
class agx::MemoryPool< T >

Memory pool.

Definition at line 26 of file MemoryPool.h.

Constructor & Destructor Documentation

template<typename T >
agx::MemoryPool< T >::MemoryPool ( const char *  name = "MemoryPool< T >",
uint32_t  initialChunkSize = 64 
)

Constructor.

Definition at line 553 of file MemoryPool.h.

References agxAssert.

template<typename T >
agx::MemoryPool< T >::~MemoryPool ( )
virtual

Destructor.

Definition at line 563 of file MemoryPool.h.

References agxTerrain::Profiler::clear().

Member Function Documentation

void * agx::BatchAllocator::allocate ( uint32_t  numBytes)
inlineinherited
void * agx::BatchAllocator::allocate ( uint32_t  numBytes,
uint32_t  alignment 
)
inlineinherited
template<typename T >
T * agx::MemoryPool< T >::allocate ( )
inline

Allocates one element, no constructor called.

Definition at line 571 of file MemoryPool.h.

References agx::BatchAllocator::allocate(), and m_size.

void* agx::ByteAllocator::allocateBytes ( size_t  numBytes,
size_t  alignment = 16 
)
inherited

Allocate a memory section of specified alignment.

Referenced by agx::Allocator< T >::allocate(), and agx::AlignedAllocator< T >::allocate().

template<typename T >
void agx::MemoryPool< T >::clear ( )
template<typename T >
void agx::MemoryPool< T >::clearFast ( )

Clears the memory pool without calling destructors.

Definition at line 700 of file MemoryPool.h.

References agxAssert1, agx::BatchAllocator::clear(), and m_size.

template<typename T >
T * agx::MemoryPool< T >::create ( )
inline

Allocates an element and calls its default constructor.

Definition at line 585 of file MemoryPool.h.

void agx::BatchAllocator::createChunk ( uint32_t  size)
protectedinherited
void agx::BatchAllocator::deallocate ( void *  buffer)
inlineinherited

Definition at line 517 of file MemoryPool.h.

References agxVerify.

template<typename T>
void agx::MemoryPool< T >::deallocate ( T *  element)
inline

Deallocates one element, no destructor called.

Definition at line 593 of file MemoryPool.h.

References m_size.

void agx::ByteAllocator::deallocateBytes ( void *  buffer)
inherited

Definition at line 173 of file Allocator.h.

References agx::ByteAllocator::deallocateBytes().

template<typename T >
void agx::MemoryPool< T >::deallocateVirtual ( void *  ptr)
virtual

Implements agx::AbstractMemoryPool.

Definition at line 610 of file MemoryPool.h.

size_t agx::BatchAllocator::deleteAllChunks ( )
protectedinherited
template<typename T>
void agx::MemoryPool< T >::destroy ( T *  element)
inline

Deallocates an element and calls its destructor.

Definition at line 603 of file MemoryPool.h.

const char * agx::ByteAllocator::getName ( ) const
inherited
Returns
The name

Definition at line 164 of file Allocator.h.

static void agx::ByteAllocator::initMemory ( void *  data,
size_t  numBytes,
agx::UInt32  pattern 
)
staticinherited
size_t agx::BatchAllocator::size ( )
inlineinherited
template<typename T>
size_t agx::MemoryPool< T >::size ( ) const
inline

Definition at line 139 of file MemoryPool.h.

static void* agx::ByteAllocator::standaloneAllocateBytes ( size_t  numBytes,
size_t  alignment = 16 
)
staticinherited
static void agx::ByteAllocator::standaloneDeallocateTypes ( void *  buffer)
staticinherited

Member Data Documentation

agx::UInt32 agx::ByteAllocator::allocatedMemoryPattern
staticinherited

Definition at line 79 of file Allocator.h.

agx::UInt32 agx::ByteAllocator::deallocatedMemoryPattern
staticinherited

Definition at line 80 of file Allocator.h.

bool agx::ByteAllocator::initMemoryFlag
staticinherited

Definition at line 78 of file Allocator.h.

uint32_t agx::BatchAllocator::m_chunkSize
protectedinherited

Definition at line 73 of file MemoryPool.h.

Chunk* agx::BatchAllocator::m_firstChunk
protectedinherited

Definition at line 72 of file MemoryPool.h.

Referenced by agx::BatchAllocator::allocate(), and agx::BatchAllocator::size().


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