Skip to content

Commit

Permalink
timer: Rename sleep to delay_for, reexport from tokio
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Aug 30, 2019
1 parent 3d9134d commit 0d324cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions tokio-timer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ pub use timer::{set_default, Timer};

use std::time::{Duration, Instant};

/// Create a Future that completes at `deadline`.
/// Create a Future that sleeps until `deadline`.
pub fn delay(deadline: Instant) -> Delay {
Delay::new(deadline)
}

/// Create a Future that completes in `duration` from now.
pub fn sleep(duration: Duration) -> Delay {
/// Create a Future that sleeps until `duration` from now.
///
/// Equivalent to `delay(Instant::now() + duration)`.
pub fn delay_for(duration: Duration) -> Delay {
delay(Instant::now() + duration)
}

Expand Down
4 changes: 3 additions & 1 deletion tokio/src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

0 comments on commit 0d324cf

Please sign in to comment.