Last active
May 6, 2018 01:04
-
-
Save sbstp/c12ee4648002154db156b90ffd6e5b5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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