#include <object_pool.hpp>
Public Member Functions | |
bool | acquire (T &obj) |
bool | add (const T &obj) |
bool | busy (void) |
std::vector< T > | getPool () const |
ObjectPool () | |
bool | release (const T &obj) |
unsigned | size (void) |
~ObjectPool () | |
Private Types | |
typedef std::map< T, bool, C > | poolMap |
Private Attributes | |
poolMap | pool |
An object pool class that creates and reuses objects of an arbitrary type.
Definition at line 41 of file object_pool.hpp.
typedef std::map<T, bool, C> ObjectPool< T, C >::poolMap [private] |
Definition at line 143 of file object_pool.hpp.
ObjectPool< T, C >::ObjectPool | ( | ) | [inline] |
Default constructor
Definition at line 45 of file object_pool.hpp.
ObjectPool< T, C >::~ObjectPool | ( | ) | [inline] |
Default destructor
Definition at line 49 of file object_pool.hpp.
bool ObjectPool< T, C >::acquire | ( | T & | obj | ) | [inline] |
When user code demands an object, pool first looks if there is any spare object to return. In case there is not any available object in the pool, a new object will be created and returned.
Definition at line 87 of file object_pool.hpp.
bool ObjectPool< T, C >::add | ( | const T & | obj | ) | [inline] |
This function enables one to explicitly put an object into the pool.
In case the object is already in the pool, the function returns false. Otherwise, it returns true.
Definition at line 57 of file object_pool.hpp.
bool ObjectPool< T, C >::busy | ( | void | ) | [inline] |
Definition at line 70 of file object_pool.hpp.
std::vector< T > ObjectPool< T, C >::getPool | ( | void | ) | const [inline] |
This function return a vector containing all objects in the pool
Definition at line 125 of file object_pool.hpp.
bool ObjectPool< T, C >::release | ( | const T & | obj | ) | [inline] |
This function releases an object in the pool
Definition at line 111 of file object_pool.hpp.
unsigned ObjectPool< T, C >::size | ( | void | ) | [inline] |
Number of objects in the pool
Definition at line 137 of file object_pool.hpp.
poolMap ObjectPool< T, C >::pool [private] |
Definition at line 145 of file object_pool.hpp.