📄 dbioservice.cpp.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 ****************************************************************************//*-- Compiler Controls -----------------------------------------------------*//*-- Includes --------------------------------------------------------------*/#define MYSQLPP_MYSQL_HEADERS_BURIED#include <datafarm/dbioservice.hpp>#include <boost/thread/mutex.hpp>#include <mysql++/mysql++.h>#include <unistd.h>#include <iostream>/*-- Namespace Controller --------------------------------------------------*/namespace kdd{/*-- External function prototypes ------------------------------------------*//*-- Local function prototypes ---------------------------------------------*//*--------------------------------------------------------------------------*/void dbioservice::run(){// boost::this_thread::at_thread_exit(); boost::shared_ptr<dbConnection> dbc(new dbConnection(_db.c_str(),_server.c_str(),_user.c_str(),_pass.c_str())); if((dbc->getConnection()).connected()) { connStack.push_back(dbc); } pause();}dbioservice::dbConnection& dbioservice::freeConnection() throw (dbioservice::no_free_connection){ size_t startPos=next_free_connection; while(!((connStack[next_free_connection])->isFree())) { ++next_free_connection; if(next_free_connection==connStack.size()) { next_free_connection=0; } if(next_free_connection==startPos) { throw no_free_connection(); } } connStack[next_free_connection]->occupy(); return *connStack[next_free_connection];}dbioservice::~dbioservice(){ for(size_t i=0;i<connStack.size();++i) { connStack[i]->getConnection().disconnect(); }}/*-- Namespace Ender -------------------------------------------------------*/}/*--------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -