Skip to main content

block_on

Function block_on 

Source
pub fn block_on<F: Future>(future: F) -> F::Output
Expand description

Runs future to its end on the calling thread, running other tasks of the thread’s shard meanwhile.

On a worker thread (inside a task) the call nests: the worker’s shard keeps running its other tasks, timers and IO until future completes. The task that called it is not polled again until the call returns, so a future that waits for that very task never completes.

§Panics

When nested deeper than the runtime’s max_nesting (256 by default), or when the thread’s shard cannot start (its poller cannot be made).