Add source to MultiTimeout::update_timeout.

This commit is contained in:
levlam 2023-03-08 16:19:02 +03:00
parent 17540f1c15
commit 1bf2d63539
2 changed files with 10 additions and 10 deletions

View File

@ -23,13 +23,13 @@ void MultiTimeout::set_timeout_at(int64 key, double timeout) {
bool need_update_timeout = heap_node->is_top();
timeout_queue_.fix(timeout, heap_node);
if (need_update_timeout || heap_node->is_top()) {
update_timeout();
update_timeout("set_timeout");
}
} else {
CHECK(item.second);
timeout_queue_.insert(timeout, heap_node);
if (heap_node->is_top()) {
update_timeout();
update_timeout("set_timeout 2");
}
}
}
@ -44,7 +44,7 @@ void MultiTimeout::add_timeout_at(int64 key, double timeout) {
CHECK(item.second);
timeout_queue_.insert(timeout, heap_node);
if (heap_node->is_top()) {
update_timeout();
update_timeout("add_timeout");
}
}
}
@ -60,16 +60,16 @@ void MultiTimeout::cancel_timeout(int64 key) {
items_.erase(item);
if (need_update_timeout) {
update_timeout();
update_timeout("cancel_timeout");
}
}
}
void MultiTimeout::update_timeout() {
void MultiTimeout::update_timeout(const char *source) {
if (items_.empty()) {
LOG(DEBUG) << "Cancel timeout of " << get_name();
LOG_CHECK(timeout_queue_.empty()) << get_name();
LOG_CHECK(Actor::has_timeout()) << get_name();
LOG_CHECK(timeout_queue_.empty()) << get_name() << ' ' << source;
LOG_CHECK(Actor::has_timeout()) << get_name() << ' ' << source;
Actor::cancel_timeout();
} else {
LOG(DEBUG) << "Set timeout of " << get_name() << " in " << timeout_queue_.top_key() - Time::now_cached();
@ -90,7 +90,7 @@ vector<int64> MultiTimeout::get_expired_keys(double now) {
void MultiTimeout::timeout_expired() {
vector<int64> expired_keys = get_expired_keys(Time::now_cached());
if (!items_.empty()) {
update_timeout();
update_timeout("timeout_expired");
}
for (auto key : expired_keys) {
callback_(data_, key);
@ -100,7 +100,7 @@ void MultiTimeout::timeout_expired() {
void MultiTimeout::run_all() {
vector<int64> expired_keys = get_expired_keys(Time::now_cached() + 1e10);
if (!expired_keys.empty()) {
update_timeout();
update_timeout("run_all");
}
for (auto key : expired_keys) {
callback_(data_, key);

View File

@ -71,7 +71,7 @@ class MultiTimeout final : public Actor {
KHeap<double> timeout_queue_;
std::set<Item> items_;
void update_timeout();
void update_timeout(const char *source);
void timeout_expired() final;