Objects pool template class. More...
#include <pool.h>


Public Member Functions | |
| virtual | ~pool () |
| Destructor. | |
| pool_ptr< T > | acquire (const std::string &key=std::string("")) |
| Acquire an object. | |
| int | size () const |
| Get current pool size. | |
| int | in_use () const |
| Get the number of cached entries. | |
Friends | |
| class | pool_ptr< T > |
Objects pool template class.
This is a specialized object factory class with caching feature. When acquiring an object, the factory checks the pool for the not acquired one; if none found, the factory creates one.
When the object is not needed by caller, it is returning into the pool. So, this pool class preserving time for the object creation if the object constructing or initializing is expensive.
| pool_ptr<T> dbp::pool< T >::acquire | ( | const std::string & | key = std::string("") |
) | [inline] |
Acquire an object.
Create the object instance if the instance is not found in the pool or return the instance from the pool otherwise.