safe shutdown
This commit is contained in:
@@ -138,14 +138,20 @@ void client_pool::pool::remove_expired() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void client_pool::pool::shutdown() {
|
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;
|
entry.second->shutdown = true;
|
||||||
|
|
||||||
mutex_lock lock(entry.second->mutex);
|
mutex_lock lock(entry.second->mutex);
|
||||||
entry.second->notify.notify_all();
|
entry.second->notify.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
pool_queues_.clear();
|
pool_queues.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
client_pool::client_pool() noexcept {
|
client_pool::client_pool() noexcept {
|
||||||
@@ -183,7 +189,6 @@ void client_pool::remove_client(std::string client_id) {
|
|||||||
|
|
||||||
void client_pool::remove_expired() {
|
void client_pool::remove_expired() {
|
||||||
mutex_lock pool_lock(pool_mutex_);
|
mutex_lock pool_lock(pool_mutex_);
|
||||||
|
|
||||||
for (auto &entry : pool_lookup_) {
|
for (auto &entry : pool_lookup_) {
|
||||||
entry.second->remove_expired();
|
entry.second->remove_expired();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user