let job = Job::new_repeated_async(Duration::from_secs(10), |_uuid, _l| {
Box::pin(async move {
let a = schedule::guahao::schedule_91160().await;
println!("===> {}", a);
})
}).unwrap();
but report this error:
error: generator cannot be shared between threads safely
--> src\main.rs:44:9
|
44 | / Box::pin(async move {
45 | | let a = schedule::guahao::schedule_91160().await;
46 | | println!("===> {}", a);
47 | | })
| |__________^ future created by async block is not `Sync`
|
= help: the trait `Sync` is not implemented for `(dyn std::future::Future<Output = Result<http::response::Response<hyper::body::body::Body>, hyper::error::Error>> + std::marker::Send + 'static)`
= note: required for the cast to the object type `dyn std::future::Future<Output = ()> + Sync + std::marker::Send`
How to use async function in run thread? eg:
but report this error: