@@ -80,7 +80,7 @@ mod inherited_jobserver {
8080
8181 pub ( super ) struct JobServer {
8282 /// Implicit token for this process which is obtained and will be
83- /// released in parent. Since JobTokens only give back what they got,
83+ /// released in parent. Since ` JobTokens` only give back what they got,
8484 /// there should be at most one global implicit token in the wild.
8585 ///
8686 /// Since Rust does not execute any `Drop` for global variables,
@@ -164,7 +164,7 @@ mod inherited_jobserver {
164164 helper_thread : Option < HelperThread > ,
165165 }
166166
167- impl < ' a > ActiveJobServer < ' a > {
167+ impl ActiveJobServer < ' _ > {
168168 pub ( super ) async fn acquire ( & mut self ) -> Result < JobToken , Error > {
169169 let mut has_requested_token = false ;
170170
@@ -233,19 +233,14 @@ mod inprocess_jobserver {
233233 impl JobServer {
234234 pub ( super ) fn new ( ) -> Self {
235235 // Use `NUM_JOBS` if set (it's configured by Cargo) and otherwise
236- // just fall back to a semi-reasonable number.
237- //
238- // Note that we could use `num_cpus` here but it's an extra
239- // dependency that will almost never be used, so
240- // it's generally not too worth it.
241- let mut parallelism = 4 ;
242- // TODO: Use std::thread::available_parallelism as an upper bound
243- // when MSRV is bumped.
244- if let Ok ( amt) = var ( "NUM_JOBS" ) {
245- if let Ok ( amt) = amt. parse ( ) {
246- parallelism = amt;
247- }
248- }
236+ // just fall back to the number of cores on the local machine, or a reasonable
237+ // default if that cannot be determined.
238+
239+ let parallelism = var ( "NUM_JOBS" )
240+ . ok ( )
241+ . and_then ( |j| j. parse :: < u32 > ( ) . ok ( ) )
242+ . or_else ( || Some ( std:: thread:: available_parallelism ( ) . ok ( ) ?. get ( ) as u32 ) )
243+ . unwrap_or ( 4 ) ;
249244
250245 Self ( AtomicU32 :: new ( parallelism) )
251246 }
0 commit comments