pub fn spawn_blocking<F: FnOnce() -> T + Send + 'static, T: Send + 'static>(
    f: F
) -> Task<T> 
Expand description

Runs blocking code on a thread pool.

Examples

Read the contents of a file:

let contents = async_global_executor::spawn_blocking(|| std::fs::read_to_string("file.txt")).await?;

Spawn a process:

use std::process::Command;

let out = async_global_executor::spawn_blocking(|| Command::new("dir").output()).await?;