forked from mirror/async-std
rename task::blocking to task::spawn_blocking
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
This commit is contained in:
parent
b4c1c63fd2
commit
12fdc1232d
2 changed files with 6 additions and 5 deletions
|
@ -21,7 +21,7 @@ use kv_log_macro::trace;
|
||||||
///
|
///
|
||||||
/// See also: [`task::blocking`].
|
/// 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
|
/// [spawning]: https://doc.rust-lang.org/std/thread/fn.spawn.html
|
||||||
/// [joining]: https://doc.rust-lang.org/std/thread/struct.JoinHandle.html#method.join
|
/// [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
|
/// is useful to prevent long-running synchronous operations from blocking the main futures
|
||||||
/// executor.
|
/// executor.
|
||||||
///
|
///
|
||||||
/// See also: [`task::block_on`].
|
/// See also: [`task::block_on`], [`task::spawn`].
|
||||||
///
|
///
|
||||||
/// [`task::block_on`]: fn.block_on.html
|
/// [`task::block_on`]: fn.block_on.html
|
||||||
|
/// [`task::spawn`]: fn.spawn.html
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -73,7 +74,7 @@ cfg_if::cfg_if! {
|
||||||
/// #
|
/// #
|
||||||
/// use async_std::task;
|
/// use async_std::task;
|
||||||
///
|
///
|
||||||
/// task::blocking(|| {
|
/// task::spawn_blocking(|| {
|
||||||
/// println!("long-running task here");
|
/// println!("long-running task here");
|
||||||
/// }).await;
|
/// }).await;
|
||||||
/// #
|
/// #
|
||||||
|
@ -84,10 +85,10 @@ cfg_if::cfg_if! {
|
||||||
#[cfg(any(feature = "unstable", feature = "docs"))]
|
#[cfg(any(feature = "unstable", feature = "docs"))]
|
||||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn blocking<F, R>(f: F) -> task::JoinHandle<R>
|
pub fn spawn_blocking<F, R>(f: F) -> task::JoinHandle<R>
|
||||||
where
|
where
|
||||||
F: FnOnce() -> R + Send + 'static,
|
F: FnOnce() -> R + Send + 'static,
|
||||||
R: Send + 'static,
|
R: Send + 'static,
|
||||||
{
|
{
|
||||||
blocking::spawn_blocking(future)
|
blocking::spawn(f)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue