Skip to content

Commit

Permalink
Always save the most recent waker
Browse files Browse the repository at this point in the history
  • Loading branch information
espindola committed Dec 19, 2023
1 parent 6cdf461 commit ec634cf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/conn/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ struct Waitlist {

impl Waitlist {
fn push(&mut self, waker: Waker, queue_id: QueueId) {
// The documentation of Future::poll says:
// Note that on multiple calls to poll, only the Waker from
// the Context passed to the most recent call should be
// scheduled to receive a wakeup.
//
// But the the documentation of KeyedPriorityQueue::push says:
// Adds new element to queue if missing key or replace its
// priority if key exists. In second case doesn’t replace key.
//
// This means we have to remove first to have the most recent
// waker in the queue.
self.remove(queue_id);
self.queue.push(QueuedWaker { queue_id, waker }, queue_id);
}

Expand Down

0 comments on commit ec634cf

Please sign in to comment.