Skip to content

Instantly share code, notes, and snippets.

@sbstp
Last active May 6, 2018 01:04
Show Gist options
  • Save sbstp/c12ee4648002154db156b90ffd6e5b5a to your computer and use it in GitHub Desktop.
Save sbstp/c12ee4648002154db156b90ffd6e5b5a to your computer and use it in GitHub Desktop.
fn sleep(dur: Duration) -> timer::Delay {
tokio::timer::Delay::new(Instant::now() + dur)
}
fn sleep_ms(time_ms: u64) -> timer::Delay {
sleep(Duration::from_millis(time_ms))
}
// example usage
#[async]
fn periodic() {
loop {
await!(sleep_ms(1000));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment