Trait Executor

Source
pub trait Executor {
    type Task<T>: Future<Output = T>
       where T: 'static;

    // Required methods
    fn spawn<F>(&self, future: F) -> Self::Task<F::Output>
       where F: Future + Send + 'static,
             F::Output: Send + 'static;
    fn detach<T>(&self, task: Self::Task<T>);
}
Expand description

An executor which futures can be spawned on.

Required Associated Types§

Source

type Task<T>: Future<Output = T> where T: 'static

A task which completes with the output of a future.

Taskss have abort-on-drop semantics.

Required Methods§

Source

fn spawn<F>(&self, future: F) -> Self::Task<F::Output>
where F: Future + Send + 'static, F::Output: Send + 'static,

Spawns the given future on this executor, returning a Task for the task.

Source

fn detach<T>(&self, task: Self::Task<T>)

Detaches the given task so that it can run independely in the background.

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.

Implementations on Foreign Types§

Source§

impl Executor for Scope

Source§

type Task<T> = Task<T> where T: 'static

Source§

fn spawn<F>(&self, future: F) -> Self::Task<F::Output>
where F: Future + Send + 'static, F::Output: Send + 'static,

Source§

fn detach<T: 'static>(&self, task: Self::Task<T>)

Source§

impl Executor for ScopeHandle

Source§

type Task<T> = Task<T> where T: 'static

Source§

fn spawn<F>(&self, future: F) -> Self::Task<F::Output>
where F: Future + Send + 'static, F::Output: Send + 'static,

Source§

fn detach<T: 'static>(&self, task: Self::Task<T>)

Implementors§

Source§

impl Executor for FuchsiaAsync

Source§

type Task<T> = Task<T> where T: 'static