|
libcommonc++
0.7
|
A base class for object pools. More...
#include <ObjectPool.h++>

Public Member Functions | |
| ObjectPool (uint_t size) | |
| Constructor. More... | |
| virtual | ~ObjectPool () |
| Destructor. More... | |
| virtual T * | reserve ()=0 |
| Reserve an object from the pool. More... | |
| virtual void | release (T *elem)=0 |
| Release an object back to the pool. More... | |
| uint_t | getSize () const |
| Get the size of the pool, i.e., the total number of objects (both reserved and available) in the pool. More... | |
| uint_t | getAvailable () const |
| Get the number of available (unreserved) objects in the pool. More... | |
Protected Attributes | |
| uint_t | _size |
| The size of the pool (i.e., the maximum number of objects managed by the pool). More... | |
| uint_t | _avail |
| The number of objects currently available (not reserved) in the pool. More... | |
A base class for object pools.
See DynamicObjectPool and StaticObjectPool for concrete implementations.
|
inline |
Constructor.
| size | The number of objects to allocate in the pool. |
|
inlinevirtual |
Destructor.
|
inline |
Get the number of available (unreserved) objects in the pool.
|
inline |
Get the size of the pool, i.e., the total number of objects (both reserved and available) in the pool.
|
pure virtual |
Release an object back to the pool.
The object's destructor is called before the object is released back to the pool.
| elem | The object to release. |
| ObjectPoolException | If elem is NULL. |
Implemented in DynamicObjectPool< T >, StaticObjectPool< T >, StaticObjectPool< ccxx::StreamSocket >, StaticObjectPool< _Datum >, and StaticObjectPool< _Node >.
|
pure virtual |
Reserve an object from the pool.
| ObjectPoolException | If no objects are available in the pool. |
Implemented in DynamicObjectPool< T >, StaticObjectPool< T >, StaticObjectPool< ccxx::StreamSocket >, StaticObjectPool< _Datum >, and StaticObjectPool< _Node >.
|
protected |
The number of objects currently available (not reserved) in the pool.
|
protected |
The size of the pool (i.e., the maximum number of objects managed by the pool).