Skip to content

Commit 958d3a9

Browse files
committed
add an unstable task::spawn_blocking function
Signed-off-by: Yoshua Wuyts <[email protected]>
1 parent a2744e3 commit 958d3a9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/task/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,17 @@ mod task_local;
4848
mod worker;
4949

5050
pub(crate) mod blocking;
51+
52+
/// Spawns a blocking task.
53+
///
54+
/// The task will be spawned onto a thread pool specifically dedicated to blocking tasks.
55+
#[cfg(any(feature = "unstable", feature = "docs"))]
56+
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
57+
#[inline]
58+
pub fn spawn_blocking<F, R>(future: F) -> blocking::JoinHandle<R>
59+
where
60+
F: crate::future::Future<Output = R> + Send + 'static,
61+
R: Send + 'static,
62+
{
63+
blocking::spawn(future)
64+
}

0 commit comments

Comments
 (0)