mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-02 00:00:11 +02:00
runtime: stabilize LocalRuntime (#7557)
This commit is contained in:
@@ -73,16 +73,11 @@ use proc_macro::TokenStream;
|
||||
///
|
||||
/// ## Local
|
||||
///
|
||||
/// [Unstable API][unstable] only.
|
||||
///
|
||||
/// To use the [local runtime], the macro can be configured using
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[cfg(tokio_unstable)]
|
||||
/// #[tokio::main(flavor = "local")]
|
||||
/// # async fn main() {}
|
||||
/// # #[cfg(not(tokio_unstable))]
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// # Function arguments
|
||||
@@ -165,25 +160,19 @@ use proc_macro::TokenStream;
|
||||
///
|
||||
/// ## Using the local runtime
|
||||
///
|
||||
/// Available in the [unstable API][unstable] only.
|
||||
///
|
||||
/// The [local runtime] is similar to the current-thread runtime but
|
||||
/// supports [`task::spawn_local`](../tokio/task/fn.spawn_local.html).
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[cfg(tokio_unstable)]
|
||||
/// #[tokio::main(flavor = "local")]
|
||||
/// async fn main() {
|
||||
/// println!("Hello world");
|
||||
/// }
|
||||
/// # #[cfg(not(tokio_unstable))]
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// Equivalent code not using `#[tokio::main]`
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[cfg(tokio_unstable)]
|
||||
/// fn main() {
|
||||
/// tokio::runtime::Builder::new_current_thread()
|
||||
/// .enable_all()
|
||||
@@ -193,8 +182,6 @@ use proc_macro::TokenStream;
|
||||
/// println!("Hello world");
|
||||
/// })
|
||||
/// }
|
||||
/// # #[cfg(not(tokio_unstable))]
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user