pub fn off_async_worker<R>(f: impl FnOnce() -> R) -> RExpand description
Run f, handing this worker’s other tasks (and the I/O driver, if it holds
it) to another thread first when called on a multi-thread runtime worker.
Synchronous and order-preserving, unlike spawn_blocking: the caller
continues only after f returns, so a write that must land before the
next one still does.
- Multi-thread runtime worker:
block_in_place. - Blocking-pool thread, or no runtime: nothing to hand off — runs
f. - Current-thread runtime (most
#[tokio::test]s):block_in_placepanics there and there is no other worker to hand off to — runsf.