Files
IM/MS/works/db/linkDB.cpp
dongl f66340dcc0 smtp 合并到 MS 中
添加好友 取好友列表 略有修改
接下再来 要该包类型宏  备份一下
2023-05-16 17:12:05 +08:00

40 lines
770 B
C++

//
// Created by dongl on 23-4-25.
//
#include "linkDB.h"
LinkDB::LinkDB() {}
LinkDB::~LinkDB() {
delete pool;
}
ConnectionPool* LinkDB::pool = nullptr;
mysqlpp::Connection* LinkDB::safe_grab() {
// static std::vector<mysqlpp::Connection*> link;
// static std::atomic<int> index;
if (pool == nullptr) {
pool = new ConnectionPool("124.221.152.192", "ims", "IMS", "WimTFC8N58kznx2k");
// index = -1;
// for (int i = 0; i < 30; ++i) {
// link.push_back(pool->safe_grab());
// }
}
// ++index;
// if (index >= link.size()) {
// index = 0;
// }
// return link[index];
return pool->safe_grab();
}
void LinkDB::release(mysqlpp::Connection *connection) {
pool->release(connection);
}