Created
August 9, 2022 22:24
-
-
Save Akanoa/be2daf31145159a7f93d6813aaba51e8 to your computer and use it in GitHub Desktop.
Clockwerk async
This file contains hidden or 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
use clokwerk::{AsyncScheduler, TimeUnits}; | |
use std::time::Duration; | |
async fn job() { | |
dbg!("It works"); | |
} | |
#[tokio::main] | |
async fn main() { | |
let mut scheduler = AsyncScheduler::new(); | |
scheduler.every(10.seconds()).run(job); | |
loop { | |
scheduler.run_pending().await; | |
tokio::time::sleep(Duration::from_millis(100)).await; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment