pub struct HardwareInfo { /* private fields */ }Expand description
Reports non-changing information about the system hardware.
To inspect information that may change over time, use HardwareTracker.
Functions exposed by this type represent the system hardware and are not limited by the current system or process configuration. That is, this type will still count processors and memory regions that are currently inactive (e.g. some processors are physically disconnected) or are not available to this process (e.g. because of cgroups policy).
§Example
use many_cpus::HardwareInfo;
let max_processor_id = HardwareInfo::max_processor_id();
println!("The maximum processor ID is: {max_processor_id}");Implementations§
Source§impl HardwareInfo
impl HardwareInfo
Sourcepub fn max_processor_id() -> ProcessorId
pub fn max_processor_id() -> ProcessorId
Gets the maximum (inclusive) processor ID of any processor that could possibly be present on the system at any point in time.
This includes processors that are not currently active and processors that are active but not available to the current process.
Sourcepub fn max_memory_region_id() -> MemoryRegionId
pub fn max_memory_region_id() -> MemoryRegionId
Gets the maximum (inclusive) memory region ID of any memory region that could possibly be present on the system at any point in time.
This includes memory regions that are not currently active and memory regions that are active but not available to the current process.
§Example
use many_cpus::HardwareInfo;
let max_memory_region_id = HardwareInfo::max_memory_region_id();
let max_memory_region_count = HardwareInfo::max_memory_region_count();
println!("Memory region IDs range from 0 to {max_memory_region_id}");
println!("System can have up to {max_memory_region_count} memory regions");
// Useful for creating arrays indexed by memory region ID
let mut data_per_region = vec![0; max_memory_region_count];
println!(
"Created array with {} slots for memory region data",
data_per_region.len()
);Sourcepub fn max_processor_count() -> usize
pub fn max_processor_count() -> usize
Gets the maximum number of processors that could possibly be present on the system at any point in time.
This includes processors that are not currently active and processors that are active but not available to the current process.
Sourcepub fn max_memory_region_count() -> usize
pub fn max_memory_region_count() -> usize
Gets the maximum number of memory regions that could possibly be present on the system at any point in time.
This includes memory regions that are not currently active and memory regions that are active but not available to the current process.
§Example
use many_cpus::HardwareInfo;
let max_regions = HardwareInfo::max_memory_region_count();
let max_processors = HardwareInfo::max_processor_count();
println!("System architecture supports:");
println!(" Up to {max_processors} processors");
println!(" Up to {max_regions} memory regions");
let avg_processors_per_region = max_processors as f64 / max_regions as f64;
println!(
" Average of {:.1} processors per memory region",
avg_processors_per_region
);Trait Implementations§
Auto Trait Implementations§
impl Freeze for HardwareInfo
impl RefUnwindSafe for HardwareInfo
impl Send for HardwareInfo
impl Sync for HardwareInfo
impl Unpin for HardwareInfo
impl UnwindSafe for HardwareInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more