Skip to main content

spawn_background

Function spawn_background 

Source
pub fn spawn_background<F>(future: F) -> BackgroundTaskHandle<F::Output>
where F: Future + Send + 'static, F::Output: Send + 'static,
Expand description

Spawn a deferred tail on the process-global background executor.

The counterpart to spawn, and the difference is the whole point of having both: spawn follows the ambient execution model, so on a hosted build it needs a tokio runtime entered on the calling thread, while this one always lands on the same executor no matter who calls it. Record processing is reached from a plain std::thread — every blocking CA/PVA connection thread drives it through block_on_syncpark_on — so a tail it defers must not depend on the caller’s thread having a runtime.

Anything awaited inside future is subject to the same rule: use sleep_background, interval_background and spawn_blocking_background rather than their ambient counterparts, and no tokio::net socket, whose reactor this executor deliberately does not have.