From f84df6a0b1a67136f939d1bc6b7425f2b8b66ac4 Mon Sep 17 00:00:00 2001 From: dswij Date: Wed, 17 Sep 2025 21:48:18 +0800 Subject: [PATCH] refactor(pool): use `sleep` instead of `sleep_until` This commit refactors all usage of `Timer::sleep_until` with `Timer::sleep`. `sleep_until` is a convenient method that is logically equivalent with `sleep`, but requires the use of `std::time::Instant`. This have some effect when downstream users rely on non-std `Instant`. --- src/client/legacy/pool.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/client/legacy/pool.rs b/src/client/legacy/pool.rs index e0d6f2f..45cf262 100644 --- a/src/client/legacy/pool.rs +++ b/src/client/legacy/pool.rs @@ -785,7 +785,7 @@ impl IdleTask { 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 { @@ -801,8 +801,7 @@ impl IdleTask { } } - let deadline = Instant::now() + self.duration; - self.timer.reset(&mut sleep, deadline); + sleep = self.timer.sleep(self.duration); } } }