File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -492,13 +492,18 @@ impl<S> ThreadPoolBuilder<S> {
492
492
if self . num_threads > 0 {
493
493
self . num_threads
494
494
} else {
495
+ let default = || {
496
+ thread:: available_parallelism ( )
497
+ . map ( |n| n. get ( ) )
498
+ . unwrap_or ( 1 )
499
+ } ;
500
+
495
501
match env:: var ( "RAYON_NUM_THREADS" )
496
502
. ok ( )
497
503
. and_then ( |s| usize:: from_str ( & s) . ok ( ) )
498
504
{
499
- Some ( x) if x > 0 => return x,
500
- Some ( x) if x == 0 => return thread:: available_parallelism ( )
501
- . map ( |n| n. get ( ) ) . unwrap_or ( 1 ) ,
505
+ Some ( x @ 1 ..) => return x,
506
+ Some ( 0 ) => return default ( ) ,
502
507
_ => { }
503
508
}
504
509
@@ -507,8 +512,8 @@ impl<S> ThreadPoolBuilder<S> {
507
512
. ok ( )
508
513
. and_then ( |s| usize:: from_str ( & s) . ok ( ) )
509
514
{
510
- Some ( x) if x > 0 => x,
511
- _ => thread :: available_parallelism ( ) . map ( |n| n . get ( ) ) . unwrap_or ( 1 )
515
+ Some ( x @ 1 .. ) => x,
516
+ _ => default ( ) ,
512
517
}
513
518
}
514
519
}
You can’t perform that action at this time.
0 commit comments