[−][src]Macro blocking::unblock
Runs blocking code on a thread pool.
Desugaring
Note that unblock!(expr)
is syntax sugar for:
ⓘThis example is not tested
unblock(move || expr).await
Examples
Read the contents of a file:
use blocking::unblock; use std::fs; let contents = unblock!(fs::read_to_string("file.txt"))?;
Spawn a process:
use blocking::unblock; use std::process::Command; let out = unblock!(Command::new("dir").output())?;