Thread portable class


Gate portable class


Timer class


Pool class


Terimber 2.0


About C++


Downloads Products & Services Support Clients Open Source About



Home / Open source / Terimber 2.0

pool< C > Class Template Reference

creator - responsable for creation and deleting objects More...

#include <template.h>

List of all members.

Public Types

typedef C CREATOR
 responsible for creation and deletion of objects
typedef TYPENAME C::TYPE TYPE
 type of object in pool
typedef TYPENAME C::ARG ARG
 argument for creator

Public Member Functions

 pool (C &creator=C::static_constructor(), size_t pool_size=os_def_size)
 constructor
 ~pool ()
 destructor
TYPEloan_object (const ARG &arg=C::get_default_arg(), size_t timeout=C::get_default_timeout())
 returns object if it's in a pool within specified timeout
void return_object (TYPE *obj, const ARG &arg=C::get_default_arg())
 returns object back to pool
void clear (const ARG &arg=C::get_default_arg())
 clears pool
void deactivate (size_t maxrest, const ARG &arg=C::get_default_arg())
 deactivates unused objects in pool
void purge (size_t maxrest, const ARG &arg=C::get_default_arg())
 purges(deletes) unused objects in pool
void get_stats (size_t &free_objects, size_t &busy_objects) const
 gets statistics

Private Types

typedef list< pool_entrylist_pool_entry_t
 keeps the object entries as a list

Private Attributes

C & _creator
 creator reference
keylocker _locker
 read/write locker
mutex _mtx
 controls multithreaded access to pool
list_pool_entry_t _busy_objects
 pool of taken objects
list_pool_entry_t _free_objects
 pool of available objects

Classes

class  pool_entry
 pointer to a pool entry object we can't remove internl class into hpp file Microsoft specific More...


Detailed Description

template<class C>
class pool< C >

creator - responsable for creation and deleting objects

class implementating the template pool of objects

Definition at line 40 of file template.h.


Member Typedef Documentation

template<class C>
pool< C >::CREATOR

responsible for creation and deletion of objects

Definition at line 46 of file template.h.

template<class C>
pool< C >::TYPE

type of object in pool

Definition at line 49 of file template.h.

template<class C>
pool< C >::ARG

argument for creator

Definition at line 52 of file template.h.

template<class C>
pool< C >::list_pool_entry_t [private]

keeps the object entries as a list

Definition at line 96 of file template.h.


Constructor & Destructor Documentation

template<class C>
BEGIN_TERIMBER_NAMESPACE pool< C >::pool ( C &  creator = C::static_constructor(),
size_t  pool_size = os_def_size 
) [inline]

constructor

Parameters:
creator  creator
pool_size  max pool capacity

Definition at line 40 of file template.hpp.

template<class C>
pool< C >::~pool (  )  [inline]

destructor

Definition at line 46 of file template.hpp.

References pool< C >::clear().


Member Function Documentation

template<class C>
TYPENAME pool< C >::TYPE * pool< C >::loan_object ( const ARG arg = C::get_default_arg(),
size_t  timeout = C::get_default_timeout() 
) [inline]

template<class C>
void pool< C >::clear ( const ARG arg = C::get_default_arg()  )  [inline]

template<class C>
void pool< C >::deactivate ( size_t  maxrest,
const ARG arg = C::get_default_arg() 
) [inline]

deactivates unused objects in pool

Parameters:
maxrest  max time allowed for object to rest in milliseconds
arg  argument for creator

Definition at line 169 of file template.hpp.

References pool< C >::_creator, pool< C >::_free_objects, pool< C >::_mtx, base_list< T >::begin(), base_list< T >::end(), and TYPENAME.

Referenced by threadpool::v_has_job().

template<class C>
void pool< C >::purge ( size_t  maxrest,
const ARG arg = C::get_default_arg() 
) [inline]

purges(deletes) unused objects in pool

Parameters:
maxrest  max time allowed for object to rest in milliseconds
arg  argument for creator

Definition at line 192 of file template.hpp.

References pool< C >::_creator, pool< C >::_free_objects, pool< C >::_mtx, base_list< T >::begin(), base_list< T >::end(), list< T >::erase(), and TYPENAME.

template<class C>
void pool< C >::get_stats ( size_t &  free_objects,
size_t &  busy_objects 
) const [inline]

gets statistics

Parameters:
free_objects  available objects
busy_objects  objects in use

Definition at line 216 of file template.hpp.

References pool< C >::_busy_objects, pool< C >::_free_objects, pool< C >::_mtx, and list< T >::size().

Referenced by msg_communicator::doxray().


Member Data Documentation

template<class C>
C& pool< C >::_creator [private]

template<class C>
keylocker pool< C >::_locker [private]

read/write locker

Definition at line 143 of file template.h.

Referenced by pool< C >::clear(), pool< C >::loan_object(), and pool< C >::return_object().

template<class C>
mutex pool< C >::_mtx [private]

template<class C>
list_pool_entry_t pool< C >::_busy_objects [private]

pool of taken objects

Definition at line 145 of file template.h.

Referenced by pool< C >::clear(), pool< C >::get_stats(), pool< C >::loan_object(), and pool< C >::return_object().


The documentation for this class was generated from the following files:


© Copyright Terimber 2003-.