Skip to main content

run_blocking

Function run_blocking 

Source
pub fn run_blocking<F, T>(
    operation: F,
) -> impl Future<Output = Result<T, DetachedError>> + Send + 'static
where F: FnOnce() -> T + Send + 'static, T: Send + 'static,
Expand description

Start the blocking operation on the current executor’s blocking thread pool now and return a future of its output (native only: the browser event loop has no blocking pool).

Post: the returned future yields Unavailable at once when no executor is current (nothing runs), and Abandoned when operation panicked or the runtime shut down before its blocking task started (then operation never runs; see Abandoned). Otherwise the ownership law of run_detached holds: dropping the returned future abandons only the wait, and operation still runs to its end.