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> {
492492 if self . num_threads > 0 {
493493 self . num_threads
494494 } else {
495+ let default = || {
496+ thread:: available_parallelism ( )
497+ . map ( |n| n. get ( ) )
498+ . unwrap_or ( 1 )
499+ } ;
500+
495501 match env:: var ( "RAYON_NUM_THREADS" )
496502 . ok ( )
497503 . and_then ( |s| usize:: from_str ( & s) . ok ( ) )
498504 {
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 ( ) ,
502507 _ => { }
503508 }
504509
@@ -507,8 +512,8 @@ impl<S> ThreadPoolBuilder<S> {
507512 . ok ( )
508513 . and_then ( |s| usize:: from_str ( & s) . ok ( ) )
509514 {
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 ( ) ,
512517 }
513518 }
514519 }
You can’t perform that action at this time.
0 commit comments