Function spawn_blocking
pub fn spawn_blocking<T>(
f: impl FnOnce() -> T + Send + 'static,
) -> Task<Result<T, Box<dyn Any + Send>>> ⓘwhere
T: Send + 'static,Available on crate feature
runtime only.Expand description
Spawns a blocking task in a new thread, and wait for it.
The task will not be cancelled even if the future is dropped.
§Panics
This method doesn’t create runtime. It tries to obtain the current runtime
by Runtime::with_current.