TailPool< T > Class Template Reference

Simple stack-like pool. More...

#include <Memory.h>

List of all members.

Classes

struct  Chunk

Public Member Functions

 TailPool (unsigned step)
T * getMem (unsigned count=1)
 Get new memory.
void returnMem (unsigned count)
 Return allocated memory.
void reset ()

Private Attributes

vector< Chunk > chunks
 The array of all allocated chunks.
unsigned step
 The size(in elements) of each allocation.
Chunk * chunk
 Pointer to the current chunk.
unsigned chunkIndex
 The index of current chunk in the chunk array.


Detailed Description

template<typename T>
class TailPool< T >

Simple stack-like pool.

A simple pool that requires the memory to be returned in same order as it was requested. No checking of this condition is done by the pool.
The pool allocates memory in chunks. New chunk is allocated if the currently used cannot satisfy the request. The unused memory in current chunk is than waster. The maximum possible request is passed as constructor parameter.
When memory is returned, no memory is dealocated. Insted it is marked as free and ready for next requests. The allocated memory is freed only during the object destruction.


Member Function Documentation

template<typename T >
T * TailPool< T >::getMem ( unsigned  count = 1  )  [inline]

Get new memory.

Returns pointer to linear array of elements with requested size. The requested count must not be larger than the value passed to constructor.

Parameters:
count Size of requested memory in element count

template<typename T >
void TailPool< T >::returnMem ( unsigned  count  )  [inline]

Return allocated memory.

Return the previously requested memory. Must be in returned in same order as requested!!!. No memory is actualy deallocated.

Parameters:
count Size of returned memory in element count.


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

Generated on Fri Jan 23 00:21:49 2009 for Raytracer by  doxygen 1.5.7.1