metrics-rs / metrics

A metrics ecosystem for Rust.
MIT License
1.1k stars 151 forks source link

Replace num_cpus::get with std::thread::available_parallelism #500

Closed rukai closed 1 month ago

rukai commented 1 month ago

std::thread::available_parallelism was stabilized in rust 1.59, so there should be no problem in using it in this crate with an MSRV of 1.70

To remain consistent with the existing usage of num_cpus::get we default to a value of 1 if info on parallelism is inaccessible for whatever reason. The old implementation did a std::cmp::max(1, ..) but that was not needed with num_cpus since it was documented to return a max of 1, and its not needed now since we handle an error by using 1.