[][src]Struct clokwerk::Scheduler

pub struct Scheduler<Tz = Local> where
    Tz: TimeZone
{ /* fields omitted */ }

Job scheduler

Methods

impl Scheduler[src]

pub fn new() -> Self[src]

Create a new scheduler. Dates and times will be interpretted using the local timezone

pub fn with_tz<Tz: TimeZone>(tz: Tz) -> Scheduler<Tz>[src]

Create a new scheduler. Dates and times will be interpretted using the specified

impl<Tz> Scheduler<Tz> where
    Tz: TimeZone + Sync + Send
[src]

pub fn every(&mut self, ival: Interval) -> &mut Job<Tz>[src]

Add a new job to the scheduler to be run on the given interval

let mut scheduler = Scheduler::new();
scheduler.every(10.minutes()).plus(30.seconds()).run(|| println!("Periodic task"));
scheduler.every(1.day()).at("3:20 pm").run(|| println!("Daily task"));
scheduler.every(Wednesday).at("14:20:17").run(|| println!("Weekly task"));
scheduler.every(Weekday).run(|| println!("Every weekday at midnight"));

pub fn run_pending(&mut self)[src]

Run all jobs that should run at this time.

use std::thread;
use std::time::Duration;
loop {
    scheduler.run_pending();
    thread::sleep(Duration::from_millis(100));
}

impl<Tz> Scheduler<Tz> where
    Tz: TimeZone + Sync + Send + 'static,
    <Tz as TimeZone>::Offset: Send
[src]

pub fn watch_thread(self, frequency: Duration) -> ScheduleHandle[src]

Start a background thread to call Scheduler::run_pending() with the specified frequency. The resulting thread fill end cleanly if the returned ScheduleHandle is dropped.

Trait Implementations

impl Default for Scheduler[src]

impl<Tz: Debug> Debug for Scheduler<Tz> where
    Tz: TimeZone
[src]

Auto Trait Implementations

impl<Tz> Sync for Scheduler<Tz> where
    Tz: Sync,
    <Tz as TimeZone>::Offset: Sync

impl<Tz> Unpin for Scheduler<Tz> where
    Tz: Unpin,
    <Tz as TimeZone>::Offset: Unpin

impl<Tz> Send for Scheduler<Tz> where
    Tz: Send,
    <Tz as TimeZone>::Offset: Send

impl<Tz = Local> !UnwindSafe for Scheduler<Tz>

impl<Tz = Local> !RefUnwindSafe for Scheduler<Tz>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]