safe shutdown

This commit is contained in:
2025-10-04 13:49:55 -05:00
parent f3e46f4419
commit 81559a7b7e

View File

@@ -138,14 +138,20 @@ void client_pool::pool::remove_expired() {
}
void client_pool::pool::shutdown() {
for (auto &entry : pool_queues_) {
std::unordered_map<std::uint64_t, std::shared_ptr<work_queue>> pool_queues;
unique_mutex_lock pool_lock(pool_mtx_);
std::swap(pool_queues, pool_queues_);
pool_lock.unlock();
for (auto &entry : pool_queues) {
entry.second->shutdown = true;
mutex_lock lock(entry.second->mutex);
entry.second->notify.notify_all();
}
pool_queues_.clear();
pool_queues.clear();
}
client_pool::client_pool() noexcept {
@@ -183,7 +189,6 @@ void client_pool::remove_client(std::string client_id) {
void client_pool::remove_expired() {
mutex_lock pool_lock(pool_mutex_);
for (auto &entry : pool_lookup_) {
entry.second->remove_expired();
}