Skip to content

Commit

Permalink
decode: Set thread count when jobs == 0
Browse files Browse the repository at this point in the history
Use available_parallelism() as the thread count when jobs == 0.

PiperOrigin-RevId: 725661293
  • Loading branch information
vigneshvg authored and copybara-github committed Feb 11, 2025
1 parent bc23322 commit f102cd0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/crabby_decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,10 @@ fn max_threads(jobs: &Option<u32>) -> u32 {
match jobs {
Some(x) => {
if *x == 0 {
// TODO: b/394162563 - Query the number of available CPU cores for this case.
1
match std::thread::available_parallelism() {
Ok(value) => value.get() as u32,
Err(_) => 1,
}
} else {
*x
}
Expand Down

0 comments on commit f102cd0

Please sign in to comment.