Trait vortex_io::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.

Object Safety§

This trait is not object safe.

Implementors§