Fix MutliTimeout bug

GitOrigin-RevId: 7c30c7232b2462d0ad232c71bf66b7af97a9fe38
This commit is contained in:
Arseny Smirnov 2018-01-29 14:25:29 +03:00 committed by levlam
parent b40df8c118
commit e671318c99
2 changed files with 6 additions and 1 deletions

View File

@ -82,11 +82,15 @@ void MultiTimeout::timeout_expired() {
while (!timeout_queue_.empty() && timeout_queue_.top_key() < now) {
int64 key = static_cast<Item *>(timeout_queue_.pop())->key;
items_.erase(Item(key));
callback_(data_, key);
expired_.push_back(key);
}
if (!items_.empty()) {
update_timeout();
}
for (auto key : expired_) {
callback_(data_, key);
}
expired_.clear();
}
} // namespace td

View File

@ -117,6 +117,7 @@ class MultiTimeout final : public Actor {
KHeap<double> timeout_queue_;
std::set<Item> items_;
std::vector<int64> expired_;
void update_timeout();