Skip to main content

block_on

Function block_on 

Source
pub fn block_on<F>(
    runtime: &dyn Runtime,
    future: F,
) -> Result<F::Output, ProximaError>
where F: Future + Send + 'static, F::Output: Send + 'static,
Expand description

Drive future to completion on a Runtime you already HOLD, returning its output. The runtime-backed sibling of the no-runtime proxima_primitives::block_on poll loop: same verb (“drive a future to completion”), but the future runs on runtime’s core 0 worker instead of the calling thread. Composes Runtime::spawn_on_core with a sync_channel(1) for the thread-park / value handoff — the exact core of the edge run_prime driver, lifted off the concrete PrimeRuntime onto &dyn Runtime (a free fn, not a trait method, so dyn Runtime stays object-safe).

FOREIGN-THREAD entry: call this from a thread that is NOT a worker of runtime, or you deadlock the worker (the same rule as tokio::runtime::Runtime::block_on). The edge run_prime avoids this by booting a dedicated driver core; this primitive does not — it drives on core 0 and parks the caller.

§Errors

Returns ProximaError::Io if core 0’s inbox rejects the dispatch (InboxFull/Disconnected) or the worker drops the completion channel without producing a value.