rename task::blocking to task::spawn_blocking

Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
yoshuawuyts-patch-1
Yoshua Wuyts 5 years ago
parent b4c1c63fd2
commit 12fdc1232d
No known key found for this signature in database
GPG Key ID: 24EA8164F96777ED

@ -21,7 +21,7 @@ use kv_log_macro::trace;
///
/// See also: [`task::blocking`].
///
/// [`task::blocking`]: fn.blocking.html
/// [`task::spawn_blocking`]: fn.spawn_blocking.html
///
/// [spawning]: https://doc.rust-lang.org/std/thread/fn.spawn.html
/// [joining]: https://doc.rust-lang.org/std/thread/struct.JoinHandle.html#method.join

@ -60,9 +60,10 @@ cfg_if::cfg_if! {
/// is useful to prevent long-running synchronous operations from blocking the main futures
/// executor.
///
/// See also: [`task::block_on`].
/// See also: [`task::block_on`], [`task::spawn`].
///
/// [`task::block_on`]: fn.block_on.html
/// [`task::spawn`]: fn.spawn.html
///
/// # Examples
///
@ -73,7 +74,7 @@ cfg_if::cfg_if! {
/// #
/// use async_std::task;
///
/// task::blocking(|| {
/// task::spawn_blocking(|| {
/// println!("long-running task here");
/// }).await;
/// #
@ -84,10 +85,10 @@ cfg_if::cfg_if! {
#[cfg(any(feature = "unstable", feature = "docs"))]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[inline]
pub fn blocking<F, R>(f: F) -> task::JoinHandle<R>
pub fn spawn_blocking<F, R>(f: F) -> task::JoinHandle<R>
where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
blocking::spawn_blocking(future)
blocking::spawn(f)
}

Loading…
Cancel
Save