Trait Executor

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

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

An executor which futures can be spawned on.

Required Associated Types§

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

A task which completes with the output of a future.

Taskss have abort-on-drop semantics.

Required Methods§

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

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

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§

§

impl Executor for Scope

§

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

§

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

§

fn detach<T>(&self, task: <Scope as Executor>::Task<T>)
where T: 'static,

§

impl Executor for ScopeHandle

§

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

§

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

§

fn detach<T>(&self, task: <ScopeHandle as Executor>::Task<T>)
where T: 'static,

Implementors§

§

impl Executor for FuchsiaAsync

§

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