Function async_global_executor::spawn_blocking
source · [−]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?;