Skip to main content

try_spawn_blocking

Function try_spawn_blocking 

Source
pub fn try_spawn_blocking<F, T>(
    function: F,
) -> Result<JoinHandle<T>, (RuntimeConfigError, F)>
where F: FnOnce() -> T + Send + 'static, T: Send + 'static,
Expand description

Submit blocking work without consuming it when the runtime is not accepting work.

Lifecycle owners can retain the returned closure and retry it after start completes a runtime restart.

On a wasm target, prefer this over spawn_blocking – see try_spawn for why.