Fix MutliTimeout bug
GitOrigin-RevId: 7c30c7232b2462d0ad232c71bf66b7af97a9fe38
This commit is contained in:
parent
b40df8c118
commit
e671318c99
@ -82,11 +82,15 @@ void MultiTimeout::timeout_expired() {
|
|||||||
while (!timeout_queue_.empty() && timeout_queue_.top_key() < now) {
|
while (!timeout_queue_.empty() && timeout_queue_.top_key() < now) {
|
||||||
int64 key = static_cast<Item *>(timeout_queue_.pop())->key;
|
int64 key = static_cast<Item *>(timeout_queue_.pop())->key;
|
||||||
items_.erase(Item(key));
|
items_.erase(Item(key));
|
||||||
callback_(data_, key);
|
expired_.push_back(key);
|
||||||
}
|
}
|
||||||
if (!items_.empty()) {
|
if (!items_.empty()) {
|
||||||
update_timeout();
|
update_timeout();
|
||||||
}
|
}
|
||||||
|
for (auto key : expired_) {
|
||||||
|
callback_(data_, key);
|
||||||
|
}
|
||||||
|
expired_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -117,6 +117,7 @@ class MultiTimeout final : public Actor {
|
|||||||
|
|
||||||
KHeap<double> timeout_queue_;
|
KHeap<double> timeout_queue_;
|
||||||
std::set<Item> items_;
|
std::set<Item> items_;
|
||||||
|
std::vector<int64> expired_;
|
||||||
|
|
||||||
void update_timeout();
|
void update_timeout();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user