Skip to main content

get_cpu_count

Function get_cpu_count 

Source
pub fn get_cpu_count() -> usize
Expand description

Returns the number of available CPU cores.

This function attempts to detect the number of available processors on the system. If detection fails, it defaults to 1.

§Returns

A usize representing the number of available CPU cores.

§Examples

use nitrite::get_cpu_count;

let cpu_count = get_cpu_count();
println!("Available CPUs: {}", cpu_count);
assert!(cpu_count > 0);