#include <ResourcePool.hh>
Inherits fatalmind::_RPExecute< Type >.
Each resource is defined by a class called PoolType, e.g. there is a PoolType for SQL databases and TaskRunners. This type is the template arguement for a ResourcePool.
Currently ResourcePool has the following types included:
select.cc, and selectrow.cc.
Public Types | |
| typedef Type | PoolType |
| Gives access to the template parameter of ResourcePool. | |
| typedef Type::factory_t | Factory |
| The factory class used for this pool. | |
| typedef Type::command_t | Command |
| The available commands for this pool. | |
Public Member Functions | |
| ResourcePool (const typename Type::factory_t &, const ResourcePoolOptions &=ResourcePoolOptions::defaultOptions) | |
| Each ResourcePool requires a Factory, this is a class which is capable of creating new resources on demand. | |
| virtual | ~ResourcePool () |
| Destructor closes all open resources. | |
| virtual Type::resource_t & | get () |
| virtual bool | free (const typename Type::resource_t &) |
| virtual bool | fail (const typename Type::resource_t &) |
| virtual void | downsize () |
| closes unused resources. | |
| ResourcePoolStats | getStats () const |
| const Factory & | getFactory () const |
| returns a const reference to the Factory of this Pool. | |
| virtual void | execute (Command< Type > &) |
Protected Types | |
| typedef Type::ThreadingModell | TM |
| typedef TM::FastCondVar | condvar_t |
| typedef Synchronize< condvar_t > | sync_t |
|
typedef gc_ptr< typename Type::resource_t, TM > | resource_ptr |
| typedef std::deque< resource_ptr > | freePool_t |
|
typedef RefWrap< typename Type::resource_t > | plainresource_ptr |
|
typedef std::map < plainresource_ptr, resource_ptr > | usedPool_t |
Protected Member Functions | |
| bool | sleepit (int tryno) const |
| Type::resource_t * | moveToUsed () |
| virtual const ResourcePoolOptions & | getOptions () |
| void | _downsize () |
| void | _inc_pool () |
| void | _waitForFree (const CreateException &, const SingleThreadedModel<>::Type) |
| void | _waitForFree (const CreateException &, const MultiThreadedModel<>::Type) |
Friends | |
| class | fatalmind::Command< Type > |
| typedef Type::command_t fatalmind::ResourcePool< Type >::Command |
The available commands for this pool.
This is frequently used to access the commands without knowing the exact type of the ResourcePool. This is very useful to implement code which can easily migrated to another PoolType which offers the same commands.
consider this example: /code typedef ResourcePool<oracle::PoolType> RP; /endcode /verbatim RP::Command::SQLSelect /endverbatim is now equivalent to /verbatim oracle::PoolType::Command::SQLSelect/endverbatim but you don't need to know that this is for oracle.
| fatalmind::ResourcePool< Type >::ResourcePool | ( | const typename Type::factory_t & | a_factory, | |
| const ResourcePoolOptions & | a_options = ResourcePoolOptions::defaultOptions | |||
| ) | [inline] |
Each ResourcePool requires a Factory, this is a class which is capable of creating new resources on demand.
The Options have reasonable defaults, so it is not mandatory to specify them.
References fatalmind::ResourcePoolOptions::getPreCreate().
| const Factory& fatalmind::ResourcePool< Type >::getFactory | ( | ) | const [inline] |
returns a const reference to the Factory of this Pool.
The reference is valid as long as this ResourcePool itself is valid.
1.5.5