pub struct Job<'a> { /* private fields */ }
Expand description
A schedulable Job
.
Implementations§
source§impl<'a> Job<'a>
impl<'a> Job<'a>
sourcepub fn new<T>(schedule: Schedule, run: T) -> Job<'a>where
T: 'a + FnMut(),
pub fn new<T>(schedule: Schedule, run: T) -> Job<'a>where T: 'a + FnMut(),
Create a new job.
ⓘ
// Run at second 0 of the 15th minute of the 6th, 8th, and 10th hour
// of any day in March and June that is a Friday of the year 2017.
let s: Schedule = "0 15 6,8,10 * Mar,Jun Fri 2017".into().unwrap();
Job::new(s, || println!("I have a complex schedule...") );
Examples found in repository?
examples/rcron_basic.rs (lines 7-9)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
fn main() {
let mut sched = JobScheduler::new();
sched.add(Job::new("1/10 * * * * *".parse().unwrap(), || {
println!("exec task every 10 seconds!");
}));
sched.add(Job::new("1/5 * * * * *".parse().unwrap(), || {
println!("exec task every 5 seconds!");
}));
loop {
sched.tick();
std::thread::sleep(Duration::from_millis(500));
}
}
sourcepub fn limit_missed_runs(&mut self, limit: usize)
pub fn limit_missed_runs(&mut self, limit: usize)
Set the limit for missed jobs in the case of delayed runs. Setting to 0 means unlimited.
ⓘ
let mut job = Job::new("0/1 * * * * *".parse().unwrap(), || {
println!("I get executed every 1 seconds!");
});
job.limit_missed_runs(99);
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Job<'a>
impl<'a> !Send for Job<'a>
impl<'a> !Sync for Job<'a>
impl<'a> Unpin for Job<'a>
impl<'a> !UnwindSafe for Job<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more