mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-07 00:00:08 +02:00
runtime: improve runtime vs #[tokio::main] doc (#2820)
This commit is contained in:
+12
-2
@@ -26,7 +26,12 @@ use proc_macro::TokenStream;
|
|||||||
|
|
||||||
/// Marks async function to be executed by selected runtime. This macro helps set up a `Runtime`
|
/// Marks async function to be executed by selected runtime. This macro helps set up a `Runtime`
|
||||||
/// without requiring the user to use [Runtime](../tokio/runtime/struct.Runtime.html) or
|
/// without requiring the user to use [Runtime](../tokio/runtime/struct.Runtime.html) or
|
||||||
/// [Builder](../tokio/runtime/struct.builder.html) directly.
|
/// [Builder](../tokio/runtime/struct.Builder.html) directly.
|
||||||
|
///
|
||||||
|
/// Note: This macro is designed to be simplistic and targets applications that do not require
|
||||||
|
/// a complex setup. If provided functionality is not sufficient, user may be interested in
|
||||||
|
/// using [Builder](../tokio/runtime/struct.Builder.html), which provides a more powerful
|
||||||
|
/// interface.
|
||||||
///
|
///
|
||||||
/// ## Options:
|
/// ## Options:
|
||||||
///
|
///
|
||||||
@@ -133,7 +138,12 @@ pub fn main_threaded(args: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
|
|
||||||
/// Marks async function to be executed by selected runtime. This macro helps set up a `Runtime`
|
/// Marks async function to be executed by selected runtime. This macro helps set up a `Runtime`
|
||||||
/// without requiring the user to use [Runtime](../tokio/runtime/struct.Runtime.html) or
|
/// without requiring the user to use [Runtime](../tokio/runtime/struct.Runtime.html) or
|
||||||
/// [Builder](../tokio/runtime/struct.builder.html) directly.
|
/// [Builder](../tokio/runtime/struct.Builder.html) directly.
|
||||||
|
///
|
||||||
|
/// Note: This macro is designed to be simplistic and targets applications that do not require
|
||||||
|
/// a complex setup. If provided functionality is not sufficient, user may be interested in
|
||||||
|
/// using [Builder](../tokio/runtime/struct.Builder.html), which provides a more powerful
|
||||||
|
/// interface.
|
||||||
///
|
///
|
||||||
/// ## Options:
|
/// ## Options:
|
||||||
///
|
///
|
||||||
|
|||||||
+4
-3
@@ -196,9 +196,10 @@
|
|||||||
//!
|
//!
|
||||||
//! Finally, Tokio provides a _runtime_ for executing asynchronous tasks. Most
|
//! Finally, Tokio provides a _runtime_ for executing asynchronous tasks. Most
|
||||||
//! applications can use the [`#[tokio::main]`][main] macro to run their code on the
|
//! applications can use the [`#[tokio::main]`][main] macro to run their code on the
|
||||||
//! Tokio runtime. In use-cases where manual control over the runtime is
|
//! Tokio runtime. However, this macro provides only basic configuration options. As
|
||||||
//! required, the [`tokio::runtime`] module provides APIs for configuring and
|
//! an alternative, the [`tokio::runtime`] module provides more powerful APIs for configuring
|
||||||
//! managing runtimes.
|
//! and managing runtimes. You should use that module if the `#[tokio::main]` macro doesn't
|
||||||
|
//! provide the functionality you need.
|
||||||
//!
|
//!
|
||||||
//! Using the runtime requires the "rt-core" or "rt-threaded" feature flags, to
|
//! Using the runtime requires the "rt-core" or "rt-threaded" feature flags, to
|
||||||
//! enable the basic [single-threaded scheduler][rt-core] and the [thread-pool
|
//! enable the basic [single-threaded scheduler][rt-core] and the [thread-pool
|
||||||
|
|||||||
@@ -10,14 +10,14 @@
|
|||||||
//! * A **timer** for scheduling work to run after a set period of time.
|
//! * A **timer** for scheduling work to run after a set period of time.
|
||||||
//!
|
//!
|
||||||
//! Tokio's [`Runtime`] bundles all of these services as a single type, allowing
|
//! Tokio's [`Runtime`] bundles all of these services as a single type, allowing
|
||||||
//! them to be started, shut down, and configured together. However, most
|
//! them to be started, shut down, and configured together. However, often
|
||||||
//! applications won't need to use [`Runtime`] directly. Instead, they can
|
//! it is not required to configure a [`Runtime`] manually, and user may just
|
||||||
//! use the [`tokio::main`] attribute macro, which creates a [`Runtime`] under
|
//! use the [`tokio::main`] attribute macro, which creates a [`Runtime`] under
|
||||||
//! the hood.
|
//! the hood.
|
||||||
//!
|
//!
|
||||||
//! # Usage
|
//! # Usage
|
||||||
//!
|
//!
|
||||||
//! Most applications will use the [`tokio::main`] attribute macro.
|
//! When no fine tuning is required, the [`tokio::main`] attribute macro can be used.
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use tokio::net::TcpListener;
|
//! use tokio::net::TcpListener;
|
||||||
|
|||||||
Reference in New Issue
Block a user