Skip to main content

spawn_blocking

Function spawn_blocking 

Source
pub async fn spawn_blocking<R: Send + 'static>(
    f: impl FnOnce() -> R + Send + 'static,
    operation: &'static str,
) -> Result<R, SpawnError>
Expand description

Spawn a blocking function on the Rayon thread pool (LIFO scheduling).

Uses Rayon’s default LIFO scheduling for the thread’s local queue.

Includes cooperative cancellation: if the receiver is dropped before the task starts (e.g., timeout), the task is skipped without executing.

§Errors

Returns SpawnError::QueueFull if the outstanding task count exceeds the limit.