Chemical Data Processing Library C++ API - Version 1.2.0
|
A data structure that caches instances of type T
up to a user specified amount.
More...
#include <ObjectPool.hpp>
Classes | |
struct | DefaultConstructor |
struct | DefaultDestructor |
Public Types | |
typedef T | ObjectType |
typedef std::shared_ptr< ObjectType > | SharedObjectPointer |
typedef std::function< ObjectType *()> | ConstructorFunction |
typedef std::function< void(ObjectType *)> | DestructorFunction |
typedef std::function< void(ObjectType &)> | ObjectFunction |
Public Member Functions | |
ObjectPool (const ObjectPool &pool) | |
ObjectPool (std::size_t max_size=0) | |
template<typename C , typename D > | |
ObjectPool (const C &ctor_func, const D &dtor_func, std::size_t max_size=0) | |
~ObjectPool () | |
SharedObjectPointer | get () |
std::size_t | getSize () const |
std::size_t | getMaxSize () const |
void | setMaxSize (std::size_t max_size) |
void | freeMemory () |
void | setInitFunction (const ObjectFunction &func) |
void | setCleanupFunction (const ObjectFunction &func) |
ObjectPool & | operator= (const ObjectPool &pool) |
A data structure that caches instances of type T
up to a user specified amount.
Instances of type T
that are allocated via this pool (see get()) are preferentially taken from an internally maintained list of previously allocated but now unused objects. If there are no free objects a new object instance will be created on the fly. Allocated objects are returned as smart pointers which keep track of all current references to the object. If the reference count drops to zero at some point, the object is automatically returned to the pool it was allocated from.
Warning: Due to this automatic return of unused objects it is necessary that all objects have returned to their source pool before the pool instance gets destroyed!!!!
typedef T CDPL::Util::ObjectPool< T >::ObjectType |
typedef std::shared_ptr<ObjectType> CDPL::Util::ObjectPool< T >::SharedObjectPointer |
typedef std::function<ObjectType*()> CDPL::Util::ObjectPool< T >::ConstructorFunction |
typedef std::function<void(ObjectType*)> CDPL::Util::ObjectPool< T >::DestructorFunction |
typedef std::function<void(ObjectType&)> CDPL::Util::ObjectPool< T >::ObjectFunction |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |