Modify the DbClientImpl class

This commit is contained in:
antao 2019-01-09 13:12:07 +08:00
parent ac90c80710
commit e1b873ba01
1 changed files with 9 additions and 7 deletions

View File

@ -51,13 +51,15 @@ DbClientImpl::DbClientImpl(const std::string &connInfo, const size_t connNum, Cl
//LOG_DEBUG << _loops.getLoopNum();
assert(connNum > 0);
_loops.start();
for (size_t i = 0; i < _connectNum; i++)
{
auto loop = _loops.getNextLoop();
loop->runInLoop([this, loop]() {
_connections.insert(newConnection(loop));
});
}
std::thread([this]() {
for (size_t i = 0; i < _connectNum; i++)
{
auto loop = _loops.getNextLoop();
loop->runInLoop([this, loop]() {
_connections.insert(newConnection(loop));
});
}
}).detach();
}
DbClientImpl::~DbClientImpl() noexcept