Thanks for this crate. It'd be handy to use it in async programs.
run: Box<dyn (FnMut() -> ()) + 'a> causes
`dyn std::ops::FnMut()` cannot be sent between threads safely
in the following example:
use job_scheduler::{Job, JobScheduler};
use std::time::Duration;
use tokio::time::delay_for;
#[tokio::main]
async fn main() {
let mut scheduler = JobScheduler::new();
scheduler.add(Job::new("1/1 * * * * * *".parse().unwrap(), || {
dbg!("hello");
}));
tokio::spawn(async move {
loop {
scheduler.tick();
delay_for(Duration::from_millis(500)).await;
}
})
.await
.unwrap();
}
[package]
name = "hello_job_scheduler"
version = "0.1.0"
edition = "2018"
[dependencies]
job_scheduler = "1"
tokio = { version = "0.2", features = ["rt-threaded", "macros", "time"]}
Thanks for this crate. It'd be handy to use it in async programs.
run: Box<dyn (FnMut() -> ()) + 'a>
causesin the following example: