rework client using async api

This commit is contained in:
Chunting Gu
2021-04-16 19:07:31 +08:00
parent 7f345b7a4e
commit f5210ba1a2
27 changed files with 855 additions and 522 deletions
+6 -6
View File
@@ -5,11 +5,11 @@
namespace webcc {
void ConnectionPool::Start(ConnectionPtr c) {
LOG_VERB("Starting connection...");
LOG_VERB("Start connection");
{
// Lock the container only.
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<std::mutex> lock{ mutex_ };
connections_.insert(c);
}
@@ -17,11 +17,11 @@ void ConnectionPool::Start(ConnectionPtr c) {
}
void ConnectionPool::Close(ConnectionPtr c) {
LOG_VERB("Closing connection...");
LOG_VERB("Close connection");
{
// Lock the container only.
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<std::mutex> lock{ mutex_ };
connections_.erase(c);
}
@@ -30,10 +30,10 @@ void ConnectionPool::Close(ConnectionPtr c) {
void ConnectionPool::Clear() {
// Lock all since we are going to stop anyway.
std::lock_guard<std::mutex> lock(mutex_);
std::lock_guard<std::mutex> lock{ mutex_ };
if (!connections_.empty()) {
LOG_VERB("Closing all (%u) connections...", connections_.size());
LOG_VERB("Close all (%u) connections", connections_.size());
for (auto& c : connections_) {
c->Close();
}