Skip to main content

SchedulerScheduleWorkExtension

Trait SchedulerScheduleWorkExtension 

Source
pub trait SchedulerScheduleWorkExtension: Scheduler {
    // Provided methods
    fn schedule_delayed_work<Work>(
        &mut self,
        work: Work,
        delay: Duration,
        cancellation_id: WorkCancellationId,
    )
       where Work: ScheduledOnceWork<Self::Tick, Self::WorkContextProvider> { ... }
    fn schedule_repeated_work<Work>(
        &mut self,
        work: Work,
        interval: Duration,
        start_immediately: bool,
        max_work_per_tick: usize,
        cancellation_id: WorkCancellationId,
    )
       where Work: ScheduledRepeatedWork<Self::Tick, Self::WorkContextProvider> { ... }
    fn schedule_continuous_work<Work>(
        &mut self,
        work: Work,
        cancellation_id: WorkCancellationId,
    )
       where Work: ScheduledRepeatedWork<Self::Tick, Self::WorkContextProvider> { ... }
    fn schedule_immediate_work<Work>(
        &mut self,
        work: Work,
        cancellation_id: WorkCancellationId,
    )
       where Work: ScheduledOnceWork<Self::Tick, Self::WorkContextProvider> { ... }
}

Provided Methods§

Source

fn schedule_delayed_work<Work>( &mut self, work: Work, delay: Duration, cancellation_id: WorkCancellationId, )
where Work: ScheduledOnceWork<Self::Tick, Self::WorkContextProvider>,

Schedules a task that will execute once at least a delay worth of time had passed and the executor ticks.

This means that a nested series of delayed work that issues more delayed work will always drift, and the total execution time will be larger than the sum of the delays. If this is a problem, use a repeated work that has its own internal timer.

Source

fn schedule_repeated_work<Work>( &mut self, work: Work, interval: Duration, start_immediately: bool, max_work_per_tick: usize, cancellation_id: WorkCancellationId, )

Schedules a task that will execute every time the interval worth of time had passed, and the executor ticks.

If a single tick rolls the interval over multiple times, the work will also be ticked multiple times, up to max_work_per_tick, but at least once.

Source

fn schedule_continuous_work<Work>( &mut self, work: Work, cancellation_id: WorkCancellationId, )

Schedules a task that will execute every time the executor ticks! This can mean different things depending on the executor and the environment it’s used in.

For example, in a game engine, the executor is expected to be ticked once every frame, therefore a continuous work is expected to be executed once per frame. But in another environment this could mean once every 1ms. It should be ticked very often.

Source

fn schedule_immediate_work<Work>( &mut self, work: Work, cancellation_id: WorkCancellationId, )
where Work: ScheduledOnceWork<Self::Tick, Self::WorkContextProvider>,

Schedules a task that will execute as soon as the executor ticks! The cancellation_id allows the work not to be executed when it’s immediately cancelled. Preventing running work for an already closed destination for example.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§