Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/client/legacy/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ impl<T: Poolable + 'static, K: Key> IdleTask<T, K> {
async fn run(self) {
use futures_util::future;

let mut sleep = self.timer.sleep_until(Instant::now() + self.duration);
let mut sleep = self.timer.sleep(self.duration);
let mut on_pool_drop = self.pool_drop_notifier;
loop {
match future::select(&mut on_pool_drop, &mut sleep).await {
Expand All @@ -801,8 +801,7 @@ impl<T: Poolable + 'static, K: Key> IdleTask<T, K> {
}
}

let deadline = Instant::now() + self.duration;
self.timer.reset(&mut sleep, deadline);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call has the benefit of allowing implementors to reuse an allocated sleep, instead of allocating a new one...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. But I wonder if reuse instead of allocation has that much of an impact in practice.

sleep = self.timer.sleep(self.duration);
}
}
}
Expand Down
Loading