Dispatch

Trait Dispatch 

Source
pub trait Dispatch: Sealed {
    // Required methods
    fn dispatch<F, Fut, R>(&self, task: F) -> VortexResult<JoinHandle<R>>
       where F: FnOnce() -> Fut + Send + 'static,
             Fut: Future<Output = R> + 'static,
             R: Send + 'static;
    fn shutdown(self) -> VortexResult<()>;
}
Expand description

A trait for types that may be dispatched.

Required Methods§

Source

fn dispatch<F, Fut, R>(&self, task: F) -> VortexResult<JoinHandle<R>>
where F: FnOnce() -> Fut + Send + 'static, Fut: Future<Output = R> + 'static, R: Send + 'static,

Dispatch a new asynchronous task.

The function spawning the task must be Send as it will be sent to the driver thread.

The returned Future will be executed to completion on a single thread, thus it may be !Send.

Source

fn shutdown(self) -> VortexResult<()>

Gracefully shutdown the dispatcher, consuming it.

Existing tasks are awaited before exiting.

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§