Add optional source to MultiTimeout::cancel_timeout.

This commit is contained in:
levlam 2023-03-17 01:02:30 +03:00
parent f294f8c47e
commit b6a6c07de5
4 changed files with 11 additions and 11 deletions

View File

@ -790,7 +790,7 @@ void NotificationManager::try_reuse_notification_group_id(NotificationGroupId gr
CHECK(running_get_chat_difference_.count(group_id.get()) == 0);
if (!G()->close_flag()) {
flush_pending_notifications_timeout_.cancel_timeout(group_id.get());
flush_pending_notifications_timeout_.cancel_timeout(group_id.get(), "try_reuse_notification_group_id");
flush_pending_updates_timeout_.cancel_timeout(group_id.get());
}
if (pending_updates_.erase(group_id.get()) == 1) {
@ -1611,7 +1611,7 @@ void NotificationManager::flush_all_pending_notifications() {
VLOG(notifications) << "Flush pending notifications in " << group_ids.size() << " notification groups";
for (auto &it : group_ids) {
if (!G()->close_flag()) {
flush_pending_notifications_timeout_.cancel_timeout(it.second.get());
flush_pending_notifications_timeout_.cancel_timeout(it.second.get(), "flush_all_pending_notifications");
}
flush_pending_notifications(it.second);
}
@ -1865,7 +1865,7 @@ void NotificationManager::remove_notification(NotificationGroupId group_id, Noti
if (group_it->second.pending_notifications.empty()) {
group_it->second.pending_notifications_flush_time = 0;
if (!G()->close_flag()) {
flush_pending_notifications_timeout_.cancel_timeout(group_id.get());
flush_pending_notifications_timeout_.cancel_timeout(group_id.get(), "remove_notification");
}
on_delayed_notification_update_count_changed(-1, group_id.get(), "remove_notification");
}
@ -2015,7 +2015,7 @@ void NotificationManager::remove_notification_group(NotificationGroupId group_id
if (group_it->second.pending_notifications.empty()) {
group_it->second.pending_notifications_flush_time = 0;
if (!G()->close_flag()) {
flush_pending_notifications_timeout_.cancel_timeout(group_id.get());
flush_pending_notifications_timeout_.cancel_timeout(group_id.get(), "remove_notification_group");
}
on_delayed_notification_update_count_changed(-1, group_id.get(), "remove_notification_group");
}
@ -2123,7 +2123,7 @@ void NotificationManager::remove_temporary_notifications(NotificationGroupId gro
if (group.pending_notifications.empty()) {
group.pending_notifications_flush_time = 0;
if (!G()->close_flag()) {
flush_pending_notifications_timeout_.cancel_timeout(group_id.get());
flush_pending_notifications_timeout_.cancel_timeout(group_id.get(), "remove_temporary_notifications");
}
on_delayed_notification_update_count_changed(-1, group_id.get(), "remove_temporary_notifications");
}
@ -2376,7 +2376,7 @@ void NotificationManager::remove_call_notification(DialogId dialog_id, CallId ca
dialog_id_to_call_notification_group_id_.erase(dialog_id);
if (!G()->close_flag()) {
flush_pending_notifications_timeout_.cancel_timeout(group_id.get());
flush_pending_notifications_timeout_.cancel_timeout(group_id.get(), "remove_call_notification");
}
flush_pending_notifications(group_id);
force_flush_pending_updates(group_id, "reuse call group_id");

View File

@ -699,7 +699,7 @@ void PollManager::unregister_poll(PollId poll_id, FullMessageId full_message_id,
if (message_ids.empty()) {
server_poll_messages_.erase(poll_id);
if (!G()->close_flag()) {
update_poll_timeout_.cancel_timeout(poll_id.get());
update_poll_timeout_.cancel_timeout(poll_id.get(), "unregister_poll");
}
schedule_poll_unload(poll_id);
@ -1345,7 +1345,7 @@ void PollManager::on_unload_poll_timeout(PollId poll_id) {
LOG(INFO) << "Unload " << poll_id;
update_poll_timeout_.cancel_timeout(poll_id.get());
update_poll_timeout_.cancel_timeout(poll_id.get(), "on_unload_poll_timeout");
close_poll_timeout_.cancel_timeout(poll_id.get());
auto is_deleted = polls_.erase(poll_id) > 0;

View File

@ -49,7 +49,7 @@ void MultiTimeout::add_timeout_at(int64 key, double timeout) {
}
}
void MultiTimeout::cancel_timeout(int64 key) {
void MultiTimeout::cancel_timeout(int64 key, const char *source) {
LOG(DEBUG) << "Cancel " << get_name() << " for " << key;
auto item = items_.find(Item(key));
if (item != items_.end()) {
@ -60,7 +60,7 @@ void MultiTimeout::cancel_timeout(int64 key) {
items_.erase(item);
if (need_update_timeout) {
update_timeout("cancel_timeout");
update_timeout(source);
}
}
}

View File

@ -58,7 +58,7 @@ class MultiTimeout final : public Actor {
void add_timeout_at(int64 key, double timeout); // memcache semantics, doesn't replace old timeout
void cancel_timeout(int64 key);
void cancel_timeout(int64 key, const char *source = "cancel_timeout");
void run_all();