pub trait AsyncSpawner: Copy + Send + Sync + 'static {
    type JoinHandle<F>: Detach + Future + Send + Sync + 'static
       where F: Send + 'static;

    // Required methods
    fn spawn<F>(future: F) -> Self::JoinHandle<F::Output>
       where F::Output: Send + 'static,
             F: Future + Send + 'static,
             <<Self as AsyncSpawner>::JoinHandle<F> as Future>::Output: Send;
    fn spawn_detach<F>(future: F)
       where F::Output: Send + 'static,
             F: Future + Send + 'static;
}
Expand description

A spawner trait for spawning futures.

Required Associated Types§

source

type JoinHandle<F>: Detach + Future + Send + Sync + 'static where F: Send + 'static

The handle returned by the spawner when a future is spawned.

Required Methods§

source

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

Spawn a future.

source

fn spawn_detach<F>(future: F)
where F::Output: Send + 'static, F: Future + Send + 'static,

Spawn a future and detach it.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl AsyncSpawner for AsyncStdSpawner

Available on crate feature async-std only.
§

type JoinHandle<F> = JoinHandle<F> where F: Send + 'static

source§

impl AsyncSpawner for SmolSpawner

Available on crate feature smol only.
§

type JoinHandle<F> = Task<F> where F: Send + 'static

source§

impl AsyncSpawner for TokioSpawner

Available on crate feature tokio only.
§

type JoinHandle<F> = JoinHandle<F> where F: Send + 'static

source§

impl AsyncSpawner for WasmSpawner

Available on crate feature wasm only.
§

type JoinHandle<F> = WasmJoinHandle<F> where F: Send + 'static