📄 connection_pool.hpp.svn-base
字号:
/* Copy Left/Right : OTHER ,Amfproject * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; version 2 of the License. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA* **************************************************************************** * Project: LibKDD0 * Programmer: lucy * Created On: Jan 16, 2009 ****************************************************************************/#ifndef CONNECTION_POOL_HPP_#define CONNECTION_POOL_HPP_/*-- Compiler Controls -----------------------------------------------------*//*-- Includes --------------------------------------------------------------*/#include <boost/noncopyable.hpp>#include <stdexcept>#include "dbioservice.hpp"#include <vector>#include <boost/thread.hpp>#include <boost/scoped_ptr.hpp>/*-- Namespace Controller --------------------------------------------------*/namespace kdd{/*-- Extern Types ----------------------------------------------------------*//*--------------------------------------------------------------------------*/class connection_pool : private boost::noncopyable{public: class connection_pool_full : public std::runtime_error { public: connection_pool_full() : std::runtime_error("Pool Full, Wait and then Connect") { } virtual ~connection_pool_full() throw() { } }; connection_pool(std::string const &cfgfile); connection_pool(std::string const &server, std::string const& db, std::string const& user, std::string const& pass, size_t pool_init_size, size_t pool_max_size) : threadPoolInitSize(pool_init_size), threadPoolMaxSize(pool_max_size), ios(server, db, user, pass) { }// dbioservice& getIOS()// {// return ios;// } dbioservice& getIOS() { return ios; } void run(); void stopPool(); bool isStarted() const { return started; } size_t getOccupiedNumber() const { return currentThreadSize; } ~connection_pool();protected: bool started; size_t threadPoolInitSize; size_t threadPoolMaxSize; size_t currentThreadSize; std::vector<boost::shared_ptr<boost::thread> > threads; std::vector<boost::shared_ptr<boost::thread> > extraThreads; dbioservice ios;};extern connection_pool dbio;/*-- Namespace Ender -------------------------------------------------------*/}/*--------------------------------------------------------------------------*/#endif /* CONNECTION_POOL_HPP_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -