Skip to main content

block_on

Function block_on 

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

Drive a future to completion on the current thread, blocking until it resolves.

This is a minimal, dependency-free executor for tests and examples. It parks the thread between polls and wakes on Waker::wake, so a future that yields (for example, one awaiting a channel woken from another thread) makes progress without busy-spinning.

ยงExamples

let n = weaveffi::abi::block_on(async { 1 + 2 });
assert_eq!(n, 3);