fatalmind::ResourcePoolOptions Class Reference

#include <ResourcePoolOptions.hh>

List of all members.


Detailed Description

Options configuration for ResourcePool.
Examples:

select.cc.


Public Member Functions

void setMax (const int a_Max)
 Specifies the maximum concurrent resources managed by this pool.
void setMaxTry (const int a_MaxTry)
 Specifies how many dead resources the ResourcePool::get() method checks before it throws an Exception.
void setMaxExecTry (const int a_MaxExecTry)
 Specifies how often the ResourcePool::execute() method will repeate the command before it gives up.
void setPreCreate (const int a_PreCreate)
 How many resource to create on startup.
void setSleepOnFail (const SleepOnFail_t &)
 Delay if dead resources are detected.
void setSleepOnFail (const float, const float=-1, const float=-1, const float=-1)
void setWait ()
void setWait (const float)
int getPreCreate () const
int getMaxTry () const
int getMaxExecTry () const
int getMax () const
void SleepOnFail (const int) const
POSIX::timespec
< SingleThreadedModel<> > 
getSleepOnFail (int tryno) const
const timespec_t * getWait () const

Static Public Attributes

static const
ResourcePoolOptions 
defaultOptions

Classes

class  IllegalArgumentException

Member Function Documentation

void fatalmind::ResourcePoolOptions::setMax ( const int  a_Max  ) 

Specifies the maximum concurrent resources managed by this pool.

If the limit is reached the ResourcePool::get() method will throw an Exception

void fatalmind::ResourcePoolOptions::setMaxTry ( const int  a_MaxTry  ) 

Specifies how many dead resources the ResourcePool::get() method checks before it throws an Exception.

Normally the ResourcePool::get() method doesn't return dead resources (e.g. broken connections). In the case there is a broken connection in the pool, the ResourcePool::get() method throws it away and takes the next resource out of the pool. The ResourcePool::get() method tries not more then MaxTry resources before it throws an Exception.

void fatalmind::ResourcePoolOptions::setMaxExecTry ( const int  a_MaxExecTry  ) 

Specifies how often the ResourcePool::execute() method will repeate the command before it gives up.

Please have a look at the Command documentation to lern more about the Command patten and how to use it with ResourcePool.

void fatalmind::ResourcePoolOptions::setPreCreate ( const int  a_PreCreate  ) 

How many resource to create on startup.

Normally the ResourcePool creates new resources only on demand, with this option you can specify how many resources are created in advance when the ResourcePool gets constructed.

void fatalmind::ResourcePoolOptions::setSleepOnFail ( const SleepOnFail_t &  a_SleepOnFail  ) 

Delay if dead resources are detected.

You can tell the ResourcePool to sleep a while when a dead resource was found. Normally the ResourcePool::get() method tries up to MaxTry times to get a valid resource for you without any delay between the attempts. This is usually not what you want if you database is not available for a short time. Using this option you can specify a list of timeouts which should be slept between two attempts to get an valid resource.

If you have specified

ResourcePool would do the following if it isn't able to get an valid resource:

Using an exponential time scheme like this one, is usually the most efficient. However it is highly recommended to leave the first value always "0" since this is required to allow the ResourcePool to try to establish a new connection without delay.

The number of sleeps can not be more than MaxTry - 1, if you specify more values the list is truncated. If you specify less values the list is extended using the last value for the extended elements. e.g. [0, 1] in the above example would have been extended to [0, 1, 1, 1]


The documentation for this class was generated from the following files:
Generated on Mon Nov 9 16:21:24 2009 for ResourcePool by  doxygen 1.5.3