PLearn 0.1
Public Member Functions | Private Types
PLearn::PObjectPool< T > Class Template Reference

A PObjectPool is a thin wrapper around PMemPool that provides typed pointers on the allocated memory. More...

#include <PMemPool.h>

Inheritance diagram for PLearn::PObjectPool< T >:
Inheritance graph
[legend]
Collaboration diagram for PLearn::PObjectPool< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PObjectPool (size_t initial_arena_size, float growth_factor=1.5, bool use_fast_deallocator=true)
T * allocate ()
 Allocate raw memory for one object. The object is not constructed.
void deallocate (T *p)
 Deallocate raw memory from the pool.

Private Types

typedef PMemPool inherited

Detailed Description

template<class T>
class PLearn::PObjectPool< T >

A PObjectPool is a thin wrapper around PMemPool that provides typed pointers on the allocated memory.

Note that NO CONSTRUCTORS OR DESTRUCTORS are ever called on the memory; this remains the responsibility of the caller.

Definition at line 201 of file PMemPool.h.


Member Typedef Documentation

template<class T>
typedef PMemPool PLearn::PObjectPool< T >::inherited [private]

Definition at line 203 of file PMemPool.h.


Constructor & Destructor Documentation

template<class T>
PLearn::PObjectPool< T >::PObjectPool ( size_t  initial_arena_size,
float  growth_factor = 1.5,
bool  use_fast_deallocator = true 
) [inline]

Definition at line 206 of file PMemPool.h.

        : inherited(sizeof(T), initial_arena_size, growth_factor,
                    use_fast_deallocator)
    { }

Member Function Documentation

template<class T>
T* PLearn::PObjectPool< T >::allocate ( ) [inline]

Allocate raw memory for one object. The object is not constructed.

Reimplemented from PLearn::PMemPool.

Definition at line 213 of file PMemPool.h.

Referenced by alloc_from_pool(), PLearn::PythonCodeSnippet::inject(), PLearn::PythonCodeSnippet::injectInternal(), and PLearn::injectPLearnGlobalFunctions().

{ return static_cast<T*>(inherited::allocate()); }

Here is the caller graph for this function:

template<class T>
void PLearn::PObjectPool< T >::deallocate ( T *  p) [inline]

Deallocate raw memory from the pool.

The object must have been destroyed prior to calling this function.

Definition at line 217 of file PMemPool.h.

Referenced by alloc_from_pool().

Here is the caller graph for this function:


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines