You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[tokio::main(flavor = "multi_thread")]asyncfnmain() -> eyre::Result<()>{// ... existing code ...// Create a shared JobScheduler instancelet sched = JobScheduler::new().await?;let sched = Arc::new(sched);// Add a job that runs every 10 seconds
sched
.add(Job::new("1/10 * * * * *", |_uuid, _l| {println!("I run every 10 seconds");})?).await?;// Add an async job that runs every 1 minute
sched
.add(Job::new_async("every 1 minutes",move |_uuid, _l| {Box::pin(asyncmove{println!("I run every 1 minutes");let _ = perform_task_1().await;})})?).await?;// Start the scheduler in a separate task
tokio::spawn(asyncmove{
tracing::info!("Starting scheduler");let _ = sched.start().await;});// ... existing code ...}
Here, I am starting the scheduler only once for 2 scheduled jobs. And using tokio::spawn() only once.
Can someone confirm if my jobs would run in separate threads each time?
The text was updated successfully, but these errors were encountered:
This is my code:
Here, I am starting the scheduler only once for 2 scheduled jobs. And using
tokio::spawn()
only once.Can someone confirm if my jobs would run in separate threads each time?
The text was updated successfully, but these errors were encountered: