@@ -27,6 +27,9 @@ use proc_macro::TokenStream;
2727/// helps set up a `Runtime` without requiring the user to use
2828/// [Runtime](../tokio/runtime/struct.Runtime.html) or
2929/// [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.
3033///
3134/// Note: This macro is designed to be simplistic and targets applications that
3235/// do not require a complex setup. If the provided functionality is not
@@ -84,13 +87,14 @@ use proc_macro::TokenStream;
8487///
8588/// ```rust
8689/// 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()
8892/// .enable_all()
8993/// .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+ /// })
9498/// }
9599/// ```
96100///
@@ -109,13 +113,14 @@ use proc_macro::TokenStream;
109113///
110114/// ```rust
111115/// 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()
113118/// .enable_all()
114119/// .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+ /// })
119124/// }
120125/// ```
121126///
@@ -132,14 +137,15 @@ use proc_macro::TokenStream;
132137///
133138/// ```rust
134139/// 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()
136142/// .worker_threads(2)
137143/// .enable_all()
138144/// .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+ /// })
143149/// }
144150/// ```
145151///
@@ -156,14 +162,15 @@ use proc_macro::TokenStream;
156162///
157163/// ```rust
158164/// 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()
160167/// .enable_all()
161168/// .start_paused(true)
162169/// .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+ /// })
167174/// }
168175/// ```
169176///
@@ -204,13 +211,14 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
204211///
205212/// ```rust
206213/// 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()
208216/// .enable_all()
209217/// .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+ /// })
214222/// }
215223/// ```
216224///
0 commit comments