diff --git a/src/task/block_on.rs b/src/task/block_on.rs index 31588c4..e1b6d02 100644 --- a/src/task/block_on.rs +++ b/src/task/block_on.rs @@ -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 diff --git a/src/task/mod.rs b/src/task/mod.rs index 21b85fd..fc702df 100644 --- a/src/task/mod.rs +++ b/src/task/mod.rs @@ -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: F) -> task::JoinHandle +pub fn spawn_blocking(f: F) -> task::JoinHandle where F: FnOnce() -> R + Send + 'static, R: Send + 'static, { - blocking::spawn_blocking(future) + blocking::spawn(f) }