[−][src]Struct job_scheduler::JobScheduler
The JobScheduler contains and executes the scheduled jobs.
Methods
impl<'a> JobScheduler<'a>
[src]
pub fn new() -> JobScheduler<'a>
[src]
Create a new JobScheduler
.
pub fn add(&mut self, job: Job<'a>) -> Uuid
[src]
Add a job to the JobScheduler
ⓘThis example is not tested
let mut sched = JobScheduler::new(); sched.add(Job::new("1/10 * * * * *".parse().unwrap(), || { println!("I get executed every 10 seconds!"); }));
pub fn remove(&mut self, job_id: Uuid) -> bool
[src]
Remove a job from the JobScheduler
ⓘThis example is not tested
let mut sched = JobScheduler::new(); let job_id = sched.add(Job::new("1/10 * * * * *".parse().unwrap(), || { println!("I get executed every 10 seconds!"); })); sched.remove(job_id);
pub fn tick(&mut self)
[src]
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.
ⓘThis example is not tested
loop { sched.tick(); std::thread::sleep(Duration::from_millis(500)); }
pub fn time_till_next_job(&self) -> Duration
[src]
The time_till_next_job
method returns the duration till the next job
is supposed to run. This can be used to sleep until then without waking
up at a fixed interval.AsMut
ⓘThis example is not tested
loop { sched.tick(); std::thread::sleep(sched.time_till_next_job()); }
Trait Implementations
impl<'a> Default for JobScheduler<'a>
[src]
fn default() -> JobScheduler<'a>
[src]
Auto Trait Implementations
impl<'a> !RefUnwindSafe for JobScheduler<'a>
impl<'a> !Send for JobScheduler<'a>
impl<'a> !Sync for JobScheduler<'a>
impl<'a> Unpin for JobScheduler<'a>
impl<'a> !UnwindSafe for JobScheduler<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,