ObjectPool< T > Class Template Reference

A base class for object pools. More...

#include <ObjectPool.h++>

Inheritance diagram for ObjectPool< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 ObjectPool (size_t size)
 Constructor.
virtual ~ObjectPool () throw ()
 Destructor.
virtual T * reserve ()=0 throw (ObjectPoolException)
 Reserve an object from the pool.
virtual void release (T *elem)=0 throw (ObjectPoolException)
 Release an object back to the pool.
size_t getSize () const throw ()
 Get the size of the pool, i.e., the total number of objects (both reserved and available) in the pool.
uint_t getAvailable () const throw ()
 Get the number of available (unreserved) objects in the pool.

Protected Attributes

size_t _size
 The size of the pool (i.e., the maximum number of objects managed by the pool).
uint_t _avail
 The number of objects currently available (not reserved) in the pool.

Detailed Description

template<typename T>
class ccxx::ObjectPool< T >

A base class for object pools.

See DynamicObjectPool and StaticObjectPool for concrete implementations.

Author:
Mark Lindner

Constructor & Destructor Documentation

ObjectPool ( size_t  size  )  [inline]

Constructor.

Parameters:
size The number of objects to allocate in the pool.
virtual ~ObjectPool (  )  throw () [inline, virtual]

Destructor.


Member Function Documentation

uint_t getAvailable (  )  const throw () [inline]

Get the number of available (unreserved) objects in the pool.

size_t getSize (  )  const throw () [inline]

Get the size of the pool, i.e., the total number of objects (both reserved and available) in the pool.

virtual void release ( T *  elem  )  throw (ObjectPoolException) [pure virtual]

Release an object back to the pool.

The object's destructor is called before the object is released back to the pool.

Parameters:
elem The object to release.
Exceptions:
ObjectPoolException If elem is NULL.

Implemented in DynamicObjectPool< T >, StaticObjectPool< T >, StaticObjectPool< StreamSocket >, StaticObjectPool< _Datum >, and StaticObjectPool< _Node >.

virtual T* reserve (  )  throw (ObjectPoolException) [pure virtual]

Reserve an object from the pool.

Returns:
The reserved object.
Exceptions:
ObjectPoolException If no objects are available in the pool.

Implemented in DynamicObjectPool< T >, StaticObjectPool< T >, StaticObjectPool< StreamSocket >, StaticObjectPool< _Datum >, and StaticObjectPool< _Node >.


Member Data Documentation

uint_t _avail [protected]

The number of objects currently available (not reserved) in the pool.

size_t _size [protected]

The size of the pool (i.e., the maximum number of objects managed by the pool).


The documentation for this class was generated from the following file:
Generated on Sat Nov 26 16:49:09 2011 for libcommonc++ by  doxygen 1.6.3