From e3e7cdeaff713a6a33c864d0b40a9f84b7f5062b Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Sun, 26 Jul 2020 18:51:56 +0200 Subject: macros: document basic_scheduler option (#2697) --- tokio-macros/src/lib.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tokio-macros') diff --git a/tokio-macros/src/lib.rs b/tokio-macros/src/lib.rs index 64cdc4f1..1fd445d8 100644 --- a/tokio-macros/src/lib.rs +++ b/tokio-macros/src/lib.rs @@ -30,9 +30,12 @@ use proc_macro::TokenStream; /// /// ## Options: /// +/// If you want to set the number of worker threads used for asynchronous code, use the +/// `core_threads` option. /// /// - `core_threads=n` - Sets core threads to `n` (requires `rt-threaded` feature). /// - `max_threads=n` - Sets max threads to `n` (requires `rt-core` or `rt-threaded` feature). +/// - `basic_scheduler` - Use the basic schduler (requires `rt-core`). /// /// ## Function arguments: /// @@ -64,6 +67,32 @@ use proc_macro::TokenStream; /// } /// ``` /// +/// ### Using basic scheduler +/// +/// The basic scheduler is single-threaded. +/// +/// ```rust +/// #[tokio::main(basic_scheduler)] +/// async fn main() { +/// println!("Hello world"); +/// } +/// ``` +/// +/// Equivalent code not using `#[tokio::main]` +/// +/// ```rust +/// fn main() { +/// tokio::runtime::Builder::new() +/// .basic_scheduler() +/// .enable_all() +/// .build() +/// .unwrap() +/// .block_on(async { +/// println!("Hello world"); +/// }) +/// } +/// ``` +/// /// ### Set number of core threads /// /// ```rust -- cgit v1.2.3