pub fn block_on<F>(future: F) -> F::Outputwhere
F: Future,Expand description
Runs a future to completion on the current thread.
The future is polled in a simple park/wake loop backed by a condition variable. This works well for the workspace’s usage patterns, where futures are usually short-lived control flows rather than large, highly concurrent task graphs.
§Safety invariants
The custom RawWaker implementation below relies on three invariants:
- every raw pointer stored in the waker originates from
Arc<Parker>::into_raw clone,wake,wake_by_ref, anddropbalance theArcstrong count- the parker’s notification bit is cleared only immediately before polling,
so wake-ups emitted during or after the poll are still observed by
park
§Panics
Panics if writing wake-up state into the internal synchronization primitives panics, which in practice only happens if a mutex is poisoned.
§Examples
use corsa_runtime::block_on;
let value = block_on(async { 6 * 7 });
assert_eq!(value, 42);