Struct job_scheduler::JobScheduler [] [src]

pub struct JobScheduler<'a> { /* fields omitted */ }

The JobScheduler contains and executes the scheduled jobs.

Methods

impl<'a> JobScheduler<'a>
[src]

Create a new JobScheduler.

Add a job to the JobScheduler

let mut sched = JobScheduler::new();
sched.add(Job::new("1/10 * * * * *".parse().unwrap(), || {
    println!("I get executed every 10 seconds!");
}));

The tick method increments time for the JobScheduler and executes any pending jobs. It is recommended to sleep for at least 500 milliseconds between invocations of this method.

loop {
    sched.tick();
    std::thread::sleep(Duration::from_millis(500));
}

Trait Implementations

impl<'a> Default for JobScheduler<'a>
[src]

Returns the "default value" for a type. Read more