#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct NumberOfCpusToUtilize(pub Option<usize>);
impl NumberOfCpusToUtilize
{
#[inline(always)]
pub(crate) fn number_of_worker_threads_and_first_core_index(&self) -> (usize, usize)
{
#[inline(always)]
fn number_of_cpus_cap() -> usize
{
match num_cpus::get()
{
0 | 1 => 1,
other @ _ => other - 1,
}
}
let number_of_worker_threads = match self.0
{
Some(0) => 1,
Some(maximum) => min(number_of_cpus_cap(), maximum),
None => number_of_cpus_cap(),
};
if number_of_worker_threads == 1
{
(1, 0)
}
else
{
(number_of_worker_threads, 1)
}
}
}