Dali 3D User Interface Engine
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
Dali::Internal::FixedSizeMemoryPool Class Reference

Memory pool for a given fixed size of memory. More...

#include <fixed-size-memory-pool.h>

Collaboration diagram for Dali::Internal::FixedSizeMemoryPool:
Collaboration graph
[legend]

Classes

struct  Impl
 Private implementation class. More...
 

Public Types

typedef uint32_t SizeType
 

Public Member Functions

 FixedSizeMemoryPool (SizeType fixedSize, SizeType initialCapacity=32, SizeType maximumBlockCapacity=1048576)
 Constructor. More...
 
 ~FixedSizeMemoryPool ()
 Destructor. More...
 
void * Allocate ()
 Allocate a new fixed size block of memory. More...
 
void * AllocateThreadSafe ()
 Thread-safe version of Allocate() More...
 
void Free (void *memory)
 Delete a block of memory for the allocation that has been allocated by this memory pool. More...
 
void FreeThreadSafe (void *memory)
 Thread-safe version of Free() More...
 

Private Member Functions

 FixedSizeMemoryPool (const FixedSizeMemoryPool &fixedSizeMemoryPool)
 
FixedSizeMemoryPooloperator= (const FixedSizeMemoryPool &fixedSizeMemoryPool)
 

Private Attributes

ImplmImpl
 

Detailed Description

Memory pool for a given fixed size of memory.

The pool will allocate and reclaim blocks of memory without concern for what is stored in them. This means it is up to the client to construct/destruct objects and hence determine what data type is stored in the memory block. See FixedSizeObjectAllocator below for an example client for creating objects of a given type. It is also up to the client to ensure that the size of the block takes memory alignment into account for the type of data they wish to store in the block. The TypeSizeWithAlignment<T> template can be useful for determining the size of memory aligned blocks for a given type.

Definition at line 52 of file fixed-size-memory-pool.h.

Member Typedef Documentation

Definition at line 56 of file fixed-size-memory-pool.h.

Constructor & Destructor Documentation

Dali::Internal::FixedSizeMemoryPool::FixedSizeMemoryPool ( SizeType  fixedSize,
SizeType  initialCapacity = 32,
SizeType  maximumBlockCapacity = 1048576 
)
explicit

Constructor.

Parameters
fixedSizeThe fixed size of each memory allocation. Use TypeSizeWithAlignment if aligned memory is required.
initialCapacityThe initial size of the memory pool. Defaults to a small value (32) after which the capacity will double as needed.
maximumBlockCapacityThe maximum size that a new block of memory can be allocated. Defaults to a large value (1024 * 1024 = 1048576).

Definition at line 142 of file fixed-size-memory-pool.cpp.

References mImpl.

Dali::Internal::FixedSizeMemoryPool::~FixedSizeMemoryPool ( )

Destructor.

Definition at line 147 of file fixed-size-memory-pool.cpp.

References mImpl.

Dali::Internal::FixedSizeMemoryPool::FixedSizeMemoryPool ( const FixedSizeMemoryPool fixedSizeMemoryPool)
private

Member Function Documentation

void * Dali::Internal::FixedSizeMemoryPool::Allocate ( )
void * Dali::Internal::FixedSizeMemoryPool::AllocateThreadSafe ( )
void Dali::Internal::FixedSizeMemoryPool::Free ( void *  memory)

Delete a block of memory for the allocation that has been allocated by this memory pool.

Parameters
memoryThe memory to be deleted. Must have been allocated by this memory pool

Definition at line 176 of file fixed-size-memory-pool.cpp.

References Dali::Internal::FixedSizeMemoryPool::Impl::mDeletedObjects, and mImpl.

Referenced by Dali::Internal::MemoryPoolObjectAllocator< Dali::Internal::MemoryPoolRelayoutContainer::RelayoutInfo >::Free(), and FreeThreadSafe().

Here is the caller graph for this function:

void Dali::Internal::FixedSizeMemoryPool::FreeThreadSafe ( void *  memory)

Thread-safe version of Free()

Parameters
memoryThe memory to be deleted. Must have been allocated by this memory pool

Definition at line 189 of file fixed-size-memory-pool.cpp.

References Free(), mImpl, and Dali::Internal::FixedSizeMemoryPool::Impl::mMutex.

Referenced by Dali::Internal::MemoryPoolObjectAllocator< Dali::Internal::MemoryPoolRelayoutContainer::RelayoutInfo >::FreeThreadSafe().

Here is the call graph for this function:

Here is the caller graph for this function:

FixedSizeMemoryPool& Dali::Internal::FixedSizeMemoryPool::operator= ( const FixedSizeMemoryPool fixedSizeMemoryPool)
private

Member Data Documentation

Impl* Dali::Internal::FixedSizeMemoryPool::mImpl
private

The documentation for this class was generated from the following files:
Dali Docs Home
Read more about Dali