mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-11-30 10:47:40 +08:00
Fix an error when constructing RedisClientImpl objects (#840)
This commit is contained in:
parent
cb1876f26b
commit
f99c72bd5b
@ -38,14 +38,17 @@ RedisClientImpl::RedisClientImpl(const trantor::InetAddress &serverAddress,
|
||||
numberOfConnections_(numberOfConnections)
|
||||
{
|
||||
loops_.start();
|
||||
for (size_t i = 0; i < numberOfConnections_; ++i)
|
||||
{
|
||||
auto loop = loops_.getNextLoop();
|
||||
loop->queueInLoop([this, loop]() {
|
||||
std::lock_guard<std::mutex> lock(connectionsMutex_);
|
||||
connections_.insert(newConnection(loop));
|
||||
});
|
||||
}
|
||||
|
||||
std::thread([this]() {
|
||||
for (size_t i = 0; i < numberOfConnections_; ++i)
|
||||
{
|
||||
auto loop = loops_.getNextLoop();
|
||||
loop->queueInLoop([this, loop]() {
|
||||
std::lock_guard<std::mutex> lock(connectionsMutex_);
|
||||
connections_.insert(newConnection(loop));
|
||||
});
|
||||
}
|
||||
}).detach();
|
||||
}
|
||||
|
||||
RedisConnectionPtr RedisClientImpl::newConnection(trantor::EventLoop *loop)
|
||||
@ -395,4 +398,4 @@ void RedisClientImpl::execCommandAsyncWithTimeout(
|
||||
tasks_.emplace_back(bfCbPtr);
|
||||
}
|
||||
timeoutFlagPtr->runTimer();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user