Improve MultiPromiseActorSafe usage.

This commit is contained in:
levlam 2021-10-26 14:28:09 +03:00
parent 014890d720
commit 6aa090a43a

View File

@ -417,12 +417,15 @@ void ClientManager::hangup_shared() {
void ClientManager::close_db() { void ClientManager::close_db() {
LOG(WARNING) << "Closing databases"; LOG(WARNING) << "Closing databases";
td::MultiPromiseActorSafe mpromise("close binlogs"); td::MultiPromiseActorSafe mpas("close binlogs");
mpromise.add_promise(td::PromiseCreator::lambda( mpas.add_promise(td::PromiseCreator::lambda(
[actor_id = actor_id(this)](td::Unit) { send_closure(actor_id, &ClientManager::finish_close); })); [actor_id = actor_id(this)](td::Unit) { send_closure(actor_id, &ClientManager::finish_close); }));
mpas.set_ignore_errors(true);
parameters_->shared_data_->tqueue_->close(mpromise.get_promise()); auto lock = mpas.get_promise();
parameters_->shared_data_->webhook_db_->close(mpromise.get_promise()); parameters_->shared_data_->tqueue_->close(mpas.get_promise());
parameters_->shared_data_->webhook_db_->close(mpas.get_promise());
lock.set_value(td::Unit());
} }
void ClientManager::finish_close() { void ClientManager::finish_close() {