mvniekerk / tokio-cron-scheduler

Schedule tasks on Tokio using cron-like annotation
Apache License 2.0
473 stars 58 forks source link

can I use await in the job? #4

Closed mrxiaozhuox closed 2 years ago

mrxiaozhuox commented 3 years ago

How do I use the await statement in a closure function?

        self.job_scheduler.add(Job::new(schedule,|uuid, l| {
            DB_MANAGER.lock().await;
        }).unwrap());

this is my code.

mvniekerk commented 3 years ago

@mrxiaozhuox Async closures can't be done (yet). I'll check if there's maybe another around it

hgaiser commented 2 years ago

Why was this closed? I'm wondering the same thing, there doesn't seem to be a solution yet?

mvniekerk commented 2 years ago

Cucumber-rs has a way to add async closures - sort of. Plan is to glean off from it

mvniekerk commented 2 years ago

v0.3.1 has them now.