compio_runtime

Function spawn_blocking

Source
pub fn spawn_blocking<T: Send + 'static>(
    f: impl FnOnce() -> T + Send + Sync + 'static,
) -> JoinHandle<T>
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.