mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
macros: document basic_scheduler option (#2697)
This commit is contained in:
parent
7f29acd964
commit
e3e7cdeaff
@ -30,9 +30,12 @@ use proc_macro::TokenStream;
|
|||||||
///
|
///
|
||||||
/// ## Options:
|
/// ## 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).
|
/// - `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).
|
/// - `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:
|
/// ## 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
|
/// ### Set number of core threads
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
Loading…
x
Reference in New Issue
Block a user