@@ -309,12 +309,12 @@ where
309
309
impl ThreadPoolBuilder {
310
310
/// Creates a scoped `ThreadPool` initialized using this configuration.
311
311
///
312
- /// This is a convenience function for building a pool using [`crossbeam ::scope`]
312
+ /// This is a convenience function for building a pool using [`std::thread ::scope`]
313
313
/// to spawn threads in a [`spawn_handler`](#method.spawn_handler).
314
314
/// The threads in this pool will start by calling `wrapper`, which should
315
315
/// do initialization and continue by calling `ThreadBuilder::run()`.
316
316
///
317
- /// [`crossbeam:: scope`]: https://docs.rs/crossbeam/0.8/crossbeam /fn.scope.html
317
+ /// [`std::thread:: scope`]: https://doc.rust-lang.org/std/thread /fn.scope.html
318
318
///
319
319
/// # Examples
320
320
///
@@ -349,18 +349,17 @@ impl ThreadPoolBuilder {
349
349
W : Fn ( ThreadBuilder ) + Sync , // expected to call `run()`
350
350
F : FnOnce ( & ThreadPool ) -> R ,
351
351
{
352
- let result = crossbeam_utils:: thread:: scope ( |scope| {
353
- let wrapper = & wrapper;
352
+ std:: thread:: scope ( |scope| {
354
353
let pool = self
355
354
. spawn_handler ( |thread| {
356
- let mut builder = scope . builder ( ) ;
355
+ let mut builder = std :: thread :: Builder :: new ( ) ;
357
356
if let Some ( name) = thread. name ( ) {
358
357
builder = builder. name ( name. to_string ( ) ) ;
359
358
}
360
359
if let Some ( size) = thread. stack_size ( ) {
361
360
builder = builder. stack_size ( size) ;
362
361
}
363
- builder. spawn ( move |_ | wrapper ( thread) ) ?;
362
+ builder. spawn_scoped ( scope , | | wrapper ( thread) ) ?;
364
363
Ok ( ( ) )
365
364
} )
366
365
. build ( ) ?;
@@ -370,12 +369,7 @@ impl ThreadPoolBuilder {
370
369
Ok ( result) => Ok ( result) ,
371
370
Err ( err) => unwind:: resume_unwinding ( err) ,
372
371
}
373
- } ) ;
374
-
375
- match result {
376
- Ok ( result) => result,
377
- Err ( err) => unwind:: resume_unwinding ( err) ,
378
- }
372
+ } )
379
373
}
380
374
}
381
375
@@ -384,13 +378,11 @@ impl<S> ThreadPoolBuilder<S> {
384
378
///
385
379
/// Note that the threads will not exit until after the pool is dropped. It
386
380
/// is up to the caller to wait for thread termination if that is important
387
- /// for any invariants. For instance, threads created in [`crossbeam ::scope`]
381
+ /// for any invariants. For instance, threads created in [`std::thread ::scope`]
388
382
/// will be joined before that scope returns, and this will block indefinitely
389
383
/// if the pool is leaked. Furthermore, the global thread pool doesn't terminate
390
384
/// until the entire process exits!
391
385
///
392
- /// [`crossbeam::scope`]: https://docs.rs/crossbeam/0.8/crossbeam/fn.scope.html
393
- ///
394
386
/// # Examples
395
387
///
396
388
/// A minimal spawn handler just needs to call `run()` from an independent thread.
@@ -439,6 +431,7 @@ impl<S> ThreadPoolBuilder<S> {
439
431
/// or [`std::thread::scope`] introduced in Rust 1.63, which is encapsulated in
440
432
/// [`build_scoped`](#method.build_scoped).
441
433
///
434
+ /// [`crossbeam::scope`]: https://docs.rs/crossbeam/0.8/crossbeam/fn.scope.html
442
435
/// [`std::thread::scope`]: https://doc.rust-lang.org/std/thread/fn.scope.html
443
436
///
444
437
/// ```
0 commit comments