mirror of
https://github.com/async-rs/async-std.git
synced 2025-04-07 17:06:41 +00:00
Stabilize std::task::spawn_blocking
Given how widely used spawn_blocking is within async-std itself, and how useful it is for building other APIs, I think it makes sense to offer it just as we do `spawn`, even though it isn't standard in Rust itself.
This commit is contained in:
parent
264a7125e1
commit
07ba24cd87
3 changed files with 3 additions and 6 deletions
|
@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://book.async.rs/overview
|
||||||
# [Unreleased]
|
# [Unreleased]
|
||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
|
||||||
|
- `std::task_spawn_blocking` is now stabilized. We consider it a fundamental API for bridging between blocking code and async code, and we widely use it within async-std's own implementation.
|
||||||
|
|
||||||
## Removed
|
## Removed
|
||||||
## Changed
|
## Changed
|
||||||
|
|
||||||
|
|
|
@ -160,11 +160,7 @@ cfg_default! {
|
||||||
mod task_locals_wrapper;
|
mod task_locals_wrapper;
|
||||||
|
|
||||||
#[cfg(not(target_os = "unknown"))]
|
#[cfg(not(target_os = "unknown"))]
|
||||||
#[cfg(any(feature = "unstable", test))]
|
|
||||||
pub use spawn_blocking::spawn_blocking;
|
pub use spawn_blocking::spawn_blocking;
|
||||||
#[cfg(not(target_os = "unknown"))]
|
|
||||||
#[cfg(not(any(feature = "unstable", test)))]
|
|
||||||
pub(crate) use spawn_blocking::spawn_blocking;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_unstable! {
|
cfg_unstable! {
|
||||||
|
|
|
@ -16,7 +16,6 @@ use crate::task::{self, JoinHandle};
|
||||||
/// Basic usage:
|
/// Basic usage:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # #[cfg(feature = "unstable")]
|
|
||||||
/// # async_std::task::block_on(async {
|
/// # async_std::task::block_on(async {
|
||||||
/// #
|
/// #
|
||||||
/// use async_std::task;
|
/// use async_std::task;
|
||||||
|
@ -28,7 +27,6 @@ use crate::task::{self, JoinHandle};
|
||||||
/// #
|
/// #
|
||||||
/// # })
|
/// # })
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn spawn_blocking<F, T>(f: F) -> JoinHandle<T>
|
pub fn spawn_blocking<F, T>(f: F) -> JoinHandle<T>
|
||||||
where
|
where
|
||||||
|
|
Loading…
Reference in a new issue