mirror of
https://github.com/async-rs/async-std.git
synced 2025-01-31 17:55:35 +00:00
add an unstable task::spawn_blocking
function
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
This commit is contained in:
parent
a2744e3f69
commit
958d3a9e27
1 changed files with 14 additions and 0 deletions
|
@ -48,3 +48,17 @@ mod task_local;
|
||||||
mod worker;
|
mod worker;
|
||||||
|
|
||||||
pub(crate) mod blocking;
|
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)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue