Skip to main content

spawn_thread

Function spawn_thread 

Source
pub fn spawn_thread<F, T>(name: &str, f: F) -> JoinHandle<T>
where F: FnOnce() -> T + Send + 'static, T: Send + 'static,
Available on crate feature tasks only.
Expand description

Spawns a thread on the selected blocking backend.

Natively, this captures the current Tokio handle, if available, and enters it on the new OS thread so the workload can use [Handle::current()] and [Handle::spawn_blocking()]. Under fuzz plus --cfg dst, logical threads share the calling OS thread’s Tokio context. If the workload needs Tokio, enter the desired [Handle] around the entire reth_concurrency::sync::Runtime::run call, not inside individual logical threads: native context guards cannot span logical task switches.