NCBI C++ ToolKit
|
Search Toolkit Book for CResourcePool_Base
General purpose resource pool (base class, sans default constructor arguments for maximum versatility). More...
#include <util/resource_pool.hpp>
Public Types | |
typedef Value | TValue |
typedef Lock | TLock |
typedef Lock::TReadLockGuard | TReadLockGuard |
typedef Lock::TWriteLockGuard | TWriteLockGuard |
typedef CF | TClassFactory |
typedef Value * | TValuePtr |
typedef deque< Value * > | TPoolList |
Public Member Functions | |
CResourcePool_Base (size_t capacity_upper_limit, const TClassFactory &cf) | |
Construction. More... | |
~CResourcePool_Base () | |
size_t | GetCapacityLimit () const |
Return max pool size. More... | |
void | SetCapacityLimit (size_t capacity_upper_limit) |
Set upper limit for pool capacity (everything above this is deleted) More... | |
size_t | GetSize () const |
Get current pool size (number of objects in the pool) More... | |
Value * | Get () |
Get object from the pool. More... | |
Value * | GetIfAvailable () |
Get object from the pool if there is a vacancy, otherwise returns NULL. More... | |
void | Put (Value *v) |
Put object into the pool. More... | |
void | Return (Value *v) |
Value * | Forget (Value *v) |
Makes the pool to forget the object. More... | |
void | ForgetAll () |
Makes pool to forget all objects. More... | |
void | FreeAll () |
Free all pool objects. More... | |
TPoolList & | GetFreeList () |
Get internal list of free objects. More... | |
const TPoolList & | GetFreeList () const |
Get internal list of free objects. More... | |
Protected Member Functions | |
CResourcePool_Base (const CResourcePool_Base &) | |
CResourcePool_Base & | operator= (const CResourcePool_Base &) |
Protected Attributes | |
TPoolList | m_FreeObjects |
TLock | m_Lock |
TClassFactory | m_CF |
size_t | m_UpperLimit |
Upper limit how much to pool. More... | |
General purpose resource pool (base class, sans default constructor arguments for maximum versatility).
Intended use is to store reusable objects. Pool frees all vacant objects only upon pools destruction. Subsequent Get/Put calls does not result in objects reallocations and re-initializations. (So the prime target is performance optimization).
Class can be used synchronized across threads (use CFastMutex as Lock parameter)
Default creation/destruction protocol is C++ new/delete. Can be overloaded using CF parameter
Definition at line 73 of file resource_pool.hpp.