pub trait AsyncBlockingSpawner: Copy + 'static {
    type JoinHandle<R>: Detach + Send
       where R: Send + 'static;

    // Required method
    fn spawn_blocking<F, R>(f: F) -> Self::JoinHandle<R>
       where F: FnOnce() -> R + Send + 'static,
             R: Send + 'static;

    // Provided method
    fn spawn_blocking_detach<F, R>(f: F)
       where F: FnOnce() -> R + Send + 'static,
             R: Send + 'static { ... }
}
Expand description

A spawner trait for spawning blocking.

Required Associated Types§

source

type JoinHandle<R>: Detach + Send where R: Send + 'static

The join handle type for blocking tasks

Required Methods§

source

fn spawn_blocking<F, R>(f: F) -> Self::JoinHandle<R>
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,

Spawn a blocking function onto the runtime

Provided Methods§

source

fn spawn_blocking_detach<F, R>(f: F)
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,

Spawn a blocking function onto the runtime and detach it

Object Safety§

This trait is not object safe.

Implementors§

source§

impl AsyncBlockingSpawner for AsyncStdSpawner

Available on crate feature async-std only.
§

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

source§

impl AsyncBlockingSpawner for SmolSpawner

Available on crate feature smol only.
§

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

source§

impl AsyncBlockingSpawner for TokioSpawner

Available on crate feature tokio only.
§

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

source§

impl AsyncBlockingSpawner for WasmSpawner

Available on crate feature wasm only.
§

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