File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ categories = ["concurrency"]
1717
1818# Some dependencies may not be their latest version, in order to support older rustc.
1919[dependencies ]
20- num_cpus = " 1.2"
2120crossbeam-channel = " 0.5.0"
2221crossbeam-deque = " 0.8.1"
2322crossbeam-utils = " 0.8.0"
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ use std::fmt;
7373use std:: io;
7474use std:: marker:: PhantomData ;
7575use std:: str:: FromStr ;
76+ use std:: thread;
7677
7778#[ macro_use]
7879mod log;
@@ -463,7 +464,8 @@ impl<S> ThreadPoolBuilder<S> {
463464 . and_then ( |s| usize:: from_str ( & s) . ok ( ) )
464465 {
465466 Some ( x) if x > 0 => return x,
466- Some ( x) if x == 0 => return num_cpus:: get ( ) ,
467+ Some ( x) if x == 0 => return thread:: available_parallelism ( )
468+ . map ( |n| n. get ( ) ) . unwrap_or ( 1 ) ,
467469 _ => { }
468470 }
469471
@@ -473,7 +475,7 @@ impl<S> ThreadPoolBuilder<S> {
473475 . and_then ( |s| usize:: from_str ( & s) . ok ( ) )
474476 {
475477 Some ( x) if x > 0 => x,
476- _ => num_cpus :: get ( ) ,
478+ _ => thread :: available_parallelism ( ) . map ( |n| n . get ( ) ) . unwrap_or ( 1 )
477479 }
478480 }
479481 }
You can’t perform that action at this time.
0 commit comments