added initial_size ans max_size parameters for setting up db connection pool

(default to 1 and 10 respectively)
This commit is contained in:
Artem Pavlenko 2006-11-28 00:16:13 +00:00
parent 6fd7d3e488
commit 943ddf9943

View file

@ -27,6 +27,7 @@
#include <set> #include <set>
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include <boost/lexical_cast.hpp>
#include "connection_manager.hpp" #include "connection_manager.hpp"
#include "postgis.hpp" #include "postgis.hpp"
@ -53,8 +54,30 @@ postgis_datasource::postgis_datasource(parameters const& params)
params.get("user"), params.get("user"),
params.get("password")) params.get("password"))
{ {
unsigned initial_size;
unsigned max_size;
try
{
initial_size = boost::lexical_cast<unsigned>(params.get("initial_size"));
}
catch (bad_lexical_cast& )
{
initial_size = 1;
}
try
{
max_size = boost::lexical_cast<unsigned>(params.get("initial_size"));
}
catch (bad_lexical_cast&)
{
max_size = 10;
}
ConnectionManager *mgr=ConnectionManager::instance(); ConnectionManager *mgr=ConnectionManager::instance();
mgr->registerPool(creator_,5,10); mgr->registerPool(creator_, initial_size, max_size);
shared_ptr<Pool<Connection,ConnectionCreator> > pool=mgr->getPool(creator_.id()); shared_ptr<Pool<Connection,ConnectionCreator> > pool=mgr->getPool(creator_.id());
if (pool) if (pool)