@@ -46,7 +46,12 @@ use proc_macro::TokenStream;
46
46
/// Awaiting on other futures from the function provided here will not
47
47
/// perform as fast as those spawned as workers.
48
48
///
49
- /// # Multi-threaded runtime
49
+ /// # Runtime flavors
50
+ ///
51
+ /// The macro can be configured with a `flavor` parameter to select
52
+ /// different runtime configurations.
53
+ ///
54
+ /// ## Multi-threaded
50
55
///
51
56
/// To use the multi-threaded runtime, the macro can be configured using
52
57
///
@@ -61,7 +66,7 @@ use proc_macro::TokenStream;
61
66
/// Note: The multi-threaded runtime requires the `rt-multi-thread` feature
62
67
/// flag.
63
68
///
64
- /// # Current thread runtime
69
+ /// ## Current- thread
65
70
///
66
71
/// To use the single-threaded runtime known as the `current_thread` runtime,
67
72
/// the macro can be configured using
@@ -71,13 +76,13 @@ use proc_macro::TokenStream;
71
76
/// # async fn main() {}
72
77
/// ```
73
78
///
74
- /// ## Function arguments:
79
+ /// # Function arguments
75
80
///
76
- /// Arguments are allowed for any functions aside from `main` which is special
81
+ /// Arguments are allowed for any functions, aside from `main` which is special.
77
82
///
78
- /// ## Usage
83
+ /// # Usage
79
84
///
80
- /// ### Using the multi-thread runtime
85
+ /// ## Using the multi-threaded runtime
81
86
///
82
87
/// ```rust
83
88
/// #[tokio::main]
@@ -100,7 +105,7 @@ use proc_macro::TokenStream;
100
105
/// }
101
106
/// ```
102
107
///
103
- /// ### Using current thread runtime
108
+ /// ## Using the current- thread runtime
104
109
///
105
110
/// The basic scheduler is single-threaded.
106
111
///
@@ -125,7 +130,37 @@ use proc_macro::TokenStream;
125
130
/// }
126
131
/// ```
127
132
///
128
- /// ### Set number of worker threads
133
+ /// ## Using the local runtime
134
+ ///
135
+ /// Available with [`tokio_unstable`](../tokio#unstable-features) only.
136
+ ///
137
+ /// The [local runtime](../tokio/runtime/struct.LocalRuntime.html) is
138
+ /// similar to the current-thread runtime but supports
139
+ /// [`task::spawn_local`](../tokio/task/fn.spawn_local.html).
140
+ ///
141
+ /// ```rust
142
+ /// #[tokio::main(flavor = "local")]
143
+ /// async fn main() {
144
+ /// println!("Hello world");
145
+ /// }
146
+ /// ```
147
+ ///
148
+ /// Equivalent code not using `#[tokio::main]`
149
+ ///
150
+ /// ```rust
151
+ /// fn main() {
152
+ /// tokio::runtime::Builder::new_current_thread()
153
+ /// .enable_all()
154
+ /// .build_local(tokio::runtime::LocalOptions::default())
155
+ /// .unwrap()
156
+ /// .block_on(async {
157
+ /// println!("Hello world");
158
+ /// })
159
+ /// }
160
+ /// ```
161
+ ///
162
+ ///
163
+ /// ## Set number of worker threads
129
164
///
130
165
/// ```rust
131
166
/// #[tokio::main(worker_threads = 2)]
@@ -149,7 +184,7 @@ use proc_macro::TokenStream;
149
184
/// }
150
185
/// ```
151
186
///
152
- /// ### Configure the runtime to start with time paused
187
+ /// ## Configure the runtime to start with time paused
153
188
///
154
189
/// ```rust
155
190
/// #[tokio::main(flavor = "current_thread", start_paused = true)]
@@ -175,7 +210,7 @@ use proc_macro::TokenStream;
175
210
///
176
211
/// Note that `start_paused` requires the `test-util` feature to be enabled.
177
212
///
178
- /// ### Rename package
213
+ /// ## Rename package
179
214
///
180
215
/// ```rust
181
216
/// use tokio as tokio1;
@@ -202,7 +237,7 @@ use proc_macro::TokenStream;
202
237
/// }
203
238
/// ```
204
239
///
205
- /// ### Configure unhandled panic behavior
240
+ /// ## Configure unhandled panic behavior
206
241
///
207
242
/// Available options are `shutdown_runtime` and `ignore`. For more details, see
208
243
/// [`Builder::unhandled_panic`].
0 commit comments