Skip to content

Instantly share code, notes, and snippets.

@Akanoa
Created August 9, 2022 22:24
Show Gist options
  • Save Akanoa/be2daf31145159a7f93d6813aaba51e8 to your computer and use it in GitHub Desktop.
Save Akanoa/be2daf31145159a7f93d6813aaba51e8 to your computer and use it in GitHub Desktop.
Clockwerk async
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