@@ -27,6 +27,9 @@ use proc_macro::TokenStream;
27
27
/// helps set up a `Runtime` without requiring the user to use
28
28
/// [Runtime](../tokio/runtime/struct.Runtime.html) or
29
29
/// [Builder](../tokio/runtime/struct.Builder.html) directly.
30
+ /// The function executes in the context of a
31
+ /// [LocalSet](../tokio/task/struct.LocalSet.html), allowing calls to
32
+ /// [spawn_local](../tokio/task/fn.spawn_local.html) without further setup.
30
33
///
31
34
/// Note: This macro is designed to be simplistic and targets applications that
32
35
/// do not require a complex setup. If the provided functionality is not
@@ -84,13 +87,14 @@ use proc_macro::TokenStream;
84
87
///
85
88
/// ```rust
86
89
/// fn main() {
87
- /// tokio::runtime::Builder::new_multi_thread()
90
+ /// let ls = tokio::task::LocalSet::new();
91
+ /// let rt = tokio::runtime::Builder::new_multi_thread()
88
92
/// .enable_all()
89
93
/// .build()
90
- /// .unwrap()
91
- /// .block_on(async {
92
- /// println!("Hello world");
93
- /// })
94
+ /// .unwrap();
95
+ /// ls .block_on(&rt, async {
96
+ /// println!("Hello world");
97
+ /// })
94
98
/// }
95
99
/// ```
96
100
///
@@ -109,13 +113,14 @@ use proc_macro::TokenStream;
109
113
///
110
114
/// ```rust
111
115
/// fn main() {
112
- /// tokio::runtime::Builder::new_current_thread()
116
+ /// let ls = tokio::task::LocalSet::new();
117
+ /// let rt = tokio::runtime::Builder::new_current_thread()
113
118
/// .enable_all()
114
119
/// .build()
115
- /// .unwrap()
116
- /// .block_on(async {
117
- /// println!("Hello world");
118
- /// })
120
+ /// .unwrap();
121
+ /// ls .block_on(&rt, async {
122
+ /// println!("Hello world");
123
+ /// })
119
124
/// }
120
125
/// ```
121
126
///
@@ -132,14 +137,15 @@ use proc_macro::TokenStream;
132
137
///
133
138
/// ```rust
134
139
/// fn main() {
135
- /// tokio::runtime::Builder::new_multi_thread()
140
+ /// let ls = tokio::task::LocalSet::new();
141
+ /// let rt = tokio::runtime::Builder::new_multi_thread()
136
142
/// .worker_threads(2)
137
143
/// .enable_all()
138
144
/// .build()
139
- /// .unwrap()
140
- /// .block_on(async {
141
- /// println!("Hello world");
142
- /// })
145
+ /// .unwrap();
146
+ /// ls .block_on(&rt, async {
147
+ /// println!("Hello world");
148
+ /// })
143
149
/// }
144
150
/// ```
145
151
///
@@ -156,14 +162,15 @@ use proc_macro::TokenStream;
156
162
///
157
163
/// ```rust
158
164
/// fn main() {
159
- /// tokio::runtime::Builder::new_current_thread()
165
+ /// let ls = tokio::task::LocalSet::new();
166
+ /// let rt = tokio::runtime::Builder::new_current_thread()
160
167
/// .enable_all()
161
168
/// .start_paused(true)
162
169
/// .build()
163
- /// .unwrap()
164
- /// .block_on(async {
165
- /// println!("Hello world");
166
- /// })
170
+ /// .unwrap();
171
+ /// ls .block_on(&rt, async {
172
+ /// println!("Hello world");
173
+ /// })
167
174
/// }
168
175
/// ```
169
176
///
@@ -204,13 +211,14 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
204
211
///
205
212
/// ```rust
206
213
/// fn main() {
207
- /// tokio::runtime::Builder::new_current_thread()
214
+ /// let ls = tokio::task::LocalSet::new();
215
+ /// let rt = tokio::runtime::Builder::new_current_thread()
208
216
/// .enable_all()
209
217
/// .build()
210
- /// .unwrap()
211
- /// .block_on(async {
212
- /// println!("Hello world");
213
- /// })
218
+ /// .unwrap();
219
+ /// ls .block_on(&rt, async {
220
+ /// println!("Hello world");
221
+ /// })
214
222
/// }
215
223
/// ```
216
224
///
0 commit comments