Expand description
Async wrapper for blocking pool operations. Async wrapper for blocking pool operations.
This module provides spawn_blocking helpers that run blocking closures on a
runtime blocking pool when available, or a dedicated thread as a fallback.
§Cancellation Safety
When the returned future is dropped (cancelled), the blocking operation continues to run to completion on the background thread, but its result is discarded. This is the standard “soft cancellation” model for blocking operations.
§Example
ⓘ
use asupersync::runtime::spawn_blocking;
use std::io;
async fn read_file(path: &str) -> io::Result<String> {
let path = path.to_string();
spawn_blocking(move || std::fs::read_to_string(&path)).await
}Functions§
- spawn_
blocking - Spawns a blocking operation and returns a Future that yields until completion.
- spawn_
blocking_ io - Spawns a blocking I/O operation and returns a Future.