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
+4 -4
View File
@@ -6,7 +6,7 @@ namespace webcc {
ClientPool::~ClientPool() {
if (!clients_.empty()) {
LOG_INFO("Close socket for all (%u) connections in the pool.",
LOG_INFO("Close socket for all (%u) connections in the pool",
clients_.size());
for (auto& pair : clients_) {
@@ -21,21 +21,21 @@ ClientPtr ClientPool::Get(const Key& key) const {
if (it != clients_.end()) {
return it->second;
} else {
return ClientPtr{};
return {};
}
}
void ClientPool::Add(const Key& key, ClientPtr client) {
clients_[key] = client;
LOG_INFO("Added connection to pool (%s, %s, %s).",
LOG_INFO("Connection added to pool (%s, %s, %s)",
key.scheme.c_str(), key.host.c_str(), key.port.c_str());
}
void ClientPool::Remove(const Key& key) {
clients_.erase(key);
LOG_INFO("Removed connection from pool (%s, %s, %s).",
LOG_INFO("Connection removed from pool (%s, %s, %s)",
key.scheme.c_str(), key.host.c_str(), key.port.c_str());
}