diff --git a/src/task/mod.rs b/src/task/mod.rs index 9e92f35d..41b65c40 100644 --- a/src/task/mod.rs +++ b/src/task/mod.rs @@ -48,3 +48,17 @@ mod task_local; mod worker; pub(crate) mod blocking; + +/// Spawns a blocking task. +/// +/// The task will be spawned onto a thread pool specifically dedicated to blocking tasks. +#[cfg(any(feature = "unstable", feature = "docs"))] +#[cfg_attr(feature = "docs", doc(cfg(unstable)))] +#[inline] +pub fn spawn_blocking(future: F) -> blocking::JoinHandle +where + F: crate::future::Future + Send + 'static, + R: Send + 'static, +{ + blocking::spawn(future) +}