Skip to main content

AsyncRuntime

Trait AsyncRuntime 

Source
pub trait AsyncRuntime {
    type T;

    // Required method
    fn spawn<Fn, F>(&self, f: Fn) -> TaskHandle
       where Fn: FnOnce(Self::T) -> F + Send + 'static,
             F: Future<Output = ()> + Send + 'static;
}
Expand description

Executor for async service methods.

The associated type T is a per-call context passed into the spawned future and retrievable via Async::context. Use () if no extra context is needed.

See the rt module for a ready-made Tokio implementation or implement this trait directly for a custom executor.

Required Associated Types§

Source

type T

Per-call context handed to the spawned future.

Required Methods§

Source

fn spawn<Fn, F>(&self, f: Fn) -> TaskHandle
where Fn: FnOnce(Self::T) -> F + Send + 'static, F: Future<Output = ()> + Send + 'static,

Spawn a future onto the runtime, returning a handle that can abort it.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl AsyncRuntime for Tokio

Available on crate feature tokio only.
Source§

type T = ()