From d2bd6f5002f806fd2293c8ad156cdf8f756313ec Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Fri, 30 Aug 2019 10:23:54 -0700 Subject: [PATCH] timer: Rename `sleep` to `delay_for`, reexport from tokio (#1518) --- tokio-timer/src/lib.rs | 4 +++- tokio/src/timer.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tokio-timer/src/lib.rs b/tokio-timer/src/lib.rs index 030f14f61..943476664 100644 --- a/tokio-timer/src/lib.rs +++ b/tokio-timer/src/lib.rs @@ -64,7 +64,9 @@ pub fn delay(deadline: Instant) -> Delay { } /// Create a Future that completes in `duration` from now. -pub fn sleep(duration: Duration) -> Delay { +/// +/// Equivalent to `delay(Instant::now() + duration)`. Analogous to `std::thread::sleep`. +pub fn delay_for(duration: Duration) -> Delay { delay(Instant::now() + duration) } diff --git a/tokio/src/timer.rs b/tokio/src/timer.rs index 624717fcf..024903d5e 100644 --- a/tokio/src/timer.rs +++ b/tokio/src/timer.rs @@ -75,4 +75,6 @@ //! [Interval]: struct.Interval.html //! [`DelayQueue`]: struct.DelayQueue.html -pub use tokio_timer::{delay, delay_queue, timeout, Delay, DelayQueue, Error, Interval, Timeout}; +pub use tokio_timer::{ + delay, delay_for, delay_queue, timeout, Delay, DelayQueue, Error, Interval, Timeout, +};