Skip to content

Instantly share code, notes, and snippets.

@snoyberg snoyberg/main.rs Secret
Created Nov 29, 2019

Embed
What would you like to do?
use async_std::task::{sleep, spawn};
use std::time::Duration;
async fn sleepus() {
for i in 1..=10 {
println!("Sleepus {}", i);
sleep(Duration::from_millis(500)).await;
}
}
async fn interruptus() {
for i in 1..=5 {
println!("Interruptus {}", i);
sleep(Duration::from_millis(1000)).await;
}
}
fn main() {
async_std::task::block_on(async {
let sleepus = spawn(sleepus());
interruptus().await;
sleepus.await;
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.