[][src]Function async_std::task::blocking

Important traits for JoinHandle<T>
pub fn blocking<F, R>(future: F) -> JoinHandle<R> where
    F: Future<Output = R> + Send + 'static,
    R: 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.

Examples

Basic usage:

use async_std::task;

task::blocking(async {
    println!("long-running task here");
}).await;