Skip to content

Commit

Permalink
timer: introduce delay function shortcut
Browse files Browse the repository at this point in the history
This PR adds a simple delay shortcut to avoid writing Delay::new
everywhere.

Refs: #1261
  • Loading branch information
Kobzol committed Aug 14, 2019
1 parent fb9809c commit 77aaed5
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 92 deletions.
5 changes: 5 additions & 0 deletions tokio-timer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ pub fn sleep(duration: Duration) -> Delay {
Delay::new(Instant::now() + duration)
}

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

// ===== Internal utils =====

enum Round {
Expand Down
Loading

0 comments on commit 77aaed5

Please sign in to comment.