@@ -171,49 +171,49 @@ impl<'a> Executor<'a> {
171
171
}
172
172
173
173
/// Spawns many tasks onto the executor.
174
- ///
174
+ ///
175
175
/// As opposed to the [`spawn`] method, this locks the executor's inner task lock once and
176
176
/// spawns all of the tasks in one go. With large amounts of tasks this can improve
177
177
/// contention.
178
- ///
178
+ ///
179
179
/// For very large numbers of tasks the lock is occasionally dropped and re-acquired to
180
180
/// prevent runner thread starvation. It is assumed that the iterator provided does not
181
181
/// block; blocking iterators can lock up the internal mutex and therefore the entire
182
182
/// executor.
183
- ///
183
+ ///
184
184
/// ## Example
185
- ///
185
+ ///
186
186
/// ```
187
187
/// use async_executor::Executor;
188
188
/// use futures_lite::{stream, prelude::*};
189
189
/// use std::future::ready;
190
- ///
190
+ ///
191
191
/// # futures_lite::future::block_on(async {
192
192
/// let mut ex = Executor::new();
193
- ///
193
+ ///
194
194
/// let futures = [
195
195
/// ready(1),
196
196
/// ready(2),
197
197
/// ready(3)
198
198
/// ];
199
- ///
199
+ ///
200
200
/// // Spawn all of the futures onto the executor at once.
201
201
/// let mut tasks = vec![];
202
202
/// ex.spawn_many(futures, &mut tasks);
203
- ///
203
+ ///
204
204
/// // Await all of them.
205
205
/// let results = ex.run(async move {
206
206
/// stream::iter(tasks).then(|x| x).collect::<Vec<_>>().await
207
207
/// }).await;
208
208
/// assert_eq!(results, [1, 2, 3]);
209
209
/// # });
210
210
/// ```
211
- ///
211
+ ///
212
212
/// [`spawn`]: Executor::spawn
213
213
pub fn spawn_many < T : Send + ' a , F : Future < Output = T > + Send + ' a > (
214
214
& self ,
215
215
futures : impl IntoIterator < Item = F > ,
216
- handles : & mut impl Extend < Task < F :: Output > >
216
+ handles : & mut impl Extend < Task < F :: Output > > ,
217
217
) {
218
218
let mut active = self . state ( ) . active . lock ( ) . unwrap ( ) ;
219
219
@@ -494,49 +494,49 @@ impl<'a> LocalExecutor<'a> {
494
494
}
495
495
496
496
/// Spawns many tasks onto the executor.
497
- ///
497
+ ///
498
498
/// As opposed to the [`spawn`] method, this locks the executor's inner task lock once and
499
499
/// spawns all of the tasks in one go. With large amounts of tasks this can improve
500
500
/// contention.
501
- ///
501
+ ///
502
502
/// It is assumed that the iterator provided does not block; blocking iterators can lock up
503
503
/// the internal mutex and therefore the entire executor. Unlike [`Executor::spawn`], the
504
504
/// mutex is not released, as there are no other threads that can poll this executor.
505
- ///
505
+ ///
506
506
/// ## Example
507
- ///
507
+ ///
508
508
/// ```
509
509
/// use async_executor::LocalExecutor;
510
510
/// use futures_lite::{stream, prelude::*};
511
511
/// use std::future::ready;
512
- ///
512
+ ///
513
513
/// # futures_lite::future::block_on(async {
514
514
/// let mut ex = LocalExecutor::new();
515
- ///
515
+ ///
516
516
/// let futures = [
517
517
/// ready(1),
518
518
/// ready(2),
519
519
/// ready(3)
520
520
/// ];
521
- ///
521
+ ///
522
522
/// // Spawn all of the futures onto the executor at once.
523
523
/// let mut tasks = vec![];
524
524
/// ex.spawn_many(futures, &mut tasks);
525
- ///
525
+ ///
526
526
/// // Await all of them.
527
527
/// let results = ex.run(async move {
528
528
/// stream::iter(tasks).then(|x| x).collect::<Vec<_>>().await
529
529
/// }).await;
530
530
/// assert_eq!(results, [1, 2, 3]);
531
531
/// # });
532
532
/// ```
533
- ///
533
+ ///
534
534
/// [`spawn`]: LocalExecutor::spawn
535
535
/// [`Executor::spawn_many`]: Executor::spawn_many
536
536
pub fn spawn_many < T : Send + ' a , F : Future < Output = T > + Send + ' a > (
537
537
& self ,
538
538
futures : impl IntoIterator < Item = F > ,
539
- handles : & mut impl Extend < Task < F :: Output > >
539
+ handles : & mut impl Extend < Task < F :: Output > > ,
540
540
) {
541
541
let mut active = self . inner ( ) . state ( ) . active . lock ( ) . unwrap ( ) ;
542
542
@@ -1089,7 +1089,7 @@ fn debug_executor(executor: &Executor<'_>, name: &str, f: &mut fmt::Formatter<'_
1089
1089
}
1090
1090
1091
1091
/// Container with one item.
1092
- ///
1092
+ ///
1093
1093
/// This implements `Extend` for one-off cases.
1094
1094
struct Container < T > ( Option < T > ) ;
1095
1095
0 commit comments