2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-01-19 12:03:50 +00:00

add an unstable task::spawn_blocking function

Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
This commit is contained in:
Yoshua Wuyts 2019-09-28 01:37:17 +02:00
parent a2744e3f69
commit 958d3a9e27
No known key found for this signature in database
GPG key ID: 24EA8164F96777ED

View file

@ -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<F, R>(future: F) -> blocking::JoinHandle<R>
where
F: crate::future::Future<Output = R> + Send + 'static,
R: Send + 'static,
{
blocking::spawn(future)
}