Skip to main content

spawn_on_core_blocking_with

Function spawn_on_core_blocking_with 

Source
pub fn spawn_on_core_blocking_with<F>(
    runtime: &dyn Runtime,
    core_id: CoreId,
    factory: F,
) -> Result<(), SpawnError>
where F: FnMut() -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
Expand description

Loop on spawn_on_core until the future is accepted (Ok) or the target core is shut down (SpawnError::Disconnected). The factory closure is invoked once per attempt so the future is freshly constructed each time — necessary because spawn_on_core consumes the future on every call (including failures).

This is the canonical helper for batch dispatchers (load generators, bench harnesses, mass-spawn migrations) that genuinely want back-pressure absorbed at the caller via busy-yield rather than surfaced as an error. Production code that has a meaningful response to InboxFull (shed load, return 503, etc.) should call spawn_on_core directly.

Returns Ok(()) on success or Err(SpawnError::Disconnected) if the target core is gone.