summaryrefslogtreecommitdiff
path: root/examples/timer.rs
blob: 25b0e87c9e03ca03d06ec9e172dc9360410e4d1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! You may not call thread::sleep in async runtime, which will block the whole
//! thread. Instead, you should use monoio::time provided functions.

use std::time::Duration;

#[monoio::main(enable_timer = true)]
async fn main() {
    loop {
        monoio::time::sleep(Duration::from_secs(1)).await;
        println!("balabala");
        monoio::time::sleep(Duration::from_secs(1)).await;
        println!("abaaba");
    }
}