async-timer
Timer facilities for Rust's async story
Minimal Rust version: 1.36
Timed
async
async
Interval
async
async
Q&A
Q: When it is going to be async/await?
A: When async/await will become no_std
Timer facilities for Rust's async story
Minimal Rust version: 1.36
async fn job() {
}
async fn do_job() {
let work = unsafe {
async_timer::Timed::platform_new_unchecked(job(), core::time::Duration::from_secs(1))
};
match work.await {
Ok(_) => println!("I'm done!"),
//You can retry by polling `expired`
Err(expired) => println!("Job expired: {}", expired),
}
}
async fn job() {
}
async fn do_a_while() {
let mut times: u8 = 0;
let mut interval = async_timer::Interval::platform_new(core::time::Duration::from_secs(1));
while times < 5 {
job().await;
interval.as_mut().await;
times += 1;
}
}
Q: When it is going to be async/await?
A: When async/await will become no_std