Scheduler

Trait Scheduler 

Source
pub trait Scheduler:
    Clone
    + NecessarySend
    + 'static {
    // Required methods
    fn schedule_future(
        &self,
        future: impl Future<Output = ()> + NecessarySend + 'static,
    ) -> impl Disposable + NecessarySend + 'static;
    fn sleep(&self, duration: Duration) -> impl Future + NecessarySend + 'static;

    // Provided methods
    fn schedule(
        &self,
        task: impl FnOnce() + NecessarySend + 'static,
        delay: Option<Duration>,
    ) -> impl Disposable + NecessarySend + 'static { ... }
    fn schedule_recursively(
        &self,
        task: impl FnMut(usize) -> RecursionAction + NecessarySend + 'static,
        delay: Option<Duration>,
    ) -> impl Disposable + NecessarySend + 'static { ... }
    fn schedule_periodically(
        &self,
        task: impl FnMut(usize) -> bool + NecessarySend + 'static,
        period: Duration,
        delay: Option<Duration>,
    ) -> impl Disposable + NecessarySend + 'static { ... }
}
Expand description

Core abstraction for driving asynchronous work across runtimes. See https://reactivex.io/documentation/scheduler.html This is why the task must be ’static: https://stackoverflow.com/a/65287449/9315497

Required Methods§

Source

fn schedule_future( &self, future: impl Future<Output = ()> + NecessarySend + 'static, ) -> impl Disposable + NecessarySend + 'static

Source

fn sleep(&self, duration: Duration) -> impl Future + NecessarySend + 'static

Provided Methods§

Source

fn schedule( &self, task: impl FnOnce() + NecessarySend + 'static, delay: Option<Duration>, ) -> impl Disposable + NecessarySend + 'static

Source

fn schedule_recursively( &self, task: impl FnMut(usize) -> RecursionAction + NecessarySend + 'static, delay: Option<Duration>, ) -> impl Disposable + NecessarySend + 'static

Source

fn schedule_periodically( &self, task: impl FnMut(usize) -> bool + NecessarySend + 'static, period: Duration, delay: Option<Duration>, ) -> impl Disposable + NecessarySend + 'static

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§