Skip to main content

spawn_blocking

Function spawn_blocking 

Source
pub fn spawn_blocking<F, R>(f: F) -> BlockingResult<R> 
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,
Expand description

Submits blocking work and returns a future for its result.

If a system is running, work is submitted to its blocking thread pool. Otherwise, the closure runs immediately on the current thread.

Dropping the returned future prevents queued work from starting, but cannot interrupt work that is already running. Call BlockingResult::detach to let queued work continue even if its result is no longer needed.