diff options
author | sbstp <sbstp@users.noreply.github.com> | 2018-05-11 12:16:08 -0400 |
---|---|---|
committer | Carl Lerche <me@carllerche.com> | 2018-05-11 09:16:08 -0700 |
commit | 88801bb6132f3f9d624a6bbbc8bd5c9517fbc936 (patch) | |
tree | 962b109f53665fe0883b599c879e3e9371a5fb07 | |
parent | a8500632113a527780fb9c756e3d8b8a85d0f754 (diff) |
timer: add sleep free function (#347)
-rw-r--r-- | tokio-timer/src/lib.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tokio-timer/src/lib.rs b/tokio-timer/src/lib.rs index d6a0da14..1509423d 100644 --- a/tokio-timer/src/lib.rs +++ b/tokio-timer/src/lib.rs @@ -34,8 +34,15 @@ mod delay; mod error; mod interval; +use std::time::{Duration, Instant}; + pub use self::deadline::{Deadline, DeadlineError}; pub use self::delay::Delay; pub use self::error::Error; pub use self::interval::Interval; -pub use self::timer::{Timer, with_default}; +pub use self::timer::{with_default, Timer}; + +/// Create a Future that completes in `duration` from now. +pub fn sleep(duration: Duration) -> Delay { + Delay::new(Instant::now() + duration) +} |