[][src]Function async_std::task::spawn_blocking

pub fn spawn_blocking<F, T>(f: F) -> JoinHandle<T>

Notable traits for JoinHandle<T>

impl<T> Future for JoinHandle<T> type Output = T;
    F: FnOnce() -> T + Send + 'static,
    T: Send + 'static, 
This is supported on unstable only.

Spawns a blocking task.

The task will be spawned onto a thread pool specifically dedicated to blocking tasks. This is useful to prevent long-running synchronous operations from blocking the main futures executor.

See also: task::block_on, task::spawn.


Basic usage:

use async_std::task;

task::spawn_blocking(|| {
    println!("long-running task here");