Skip to main content

many_cpus/
primitive_types.rs

1/// Identifies a specific processor.
2///
3/// This will match the numeric identifier used by standard tooling of the operating system.
4///
5/// It is important to highlight that the values used are not guaranteed to be sequential/contiguous
6/// or to start from zero (aspects that are also not guaranteed by operating system tooling).
7pub type ProcessorId = u32;
8
9/// Identifies a specific memory region.
10///
11/// This will match the numeric identifier used by standard tooling of the operating system.
12///
13/// It is important to highlight that the values used are not guaranteed to be sequential/contiguous
14/// or to start from zero (aspects that are also not guaranteed by operating system tooling).
15pub type MemoryRegionId = u32;
16
17/// Differentiates processors on the performance-efficiency axis.
18///
19/// The idea behind this classification is that slower processors tend to be more energy-efficient,
20/// so we distinguish processors that should be preferred to get processing done fast from processors
21/// that should be preferred to conserve energy.
22///
23/// This is a relative measurement - the fastest processors in a system are always
24/// considered performance processors, with slower ones considered efficiency processors.
25#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
26#[expect(
27    clippy::exhaustive_enums,
28    reason = "mirroring two-tier structure of platform APIs"
29)]
30pub enum EfficiencyClass {
31    /// A processor that is optimized for energy efficiency at the expense of performance.
32    Efficiency,
33
34    /// A processor that is optimized for performance at the expense of energy efficiency.
35    Performance,
36}
37
38#[cfg(test)]
39#[cfg_attr(coverage_nightly, coverage(off))]
40mod tests {
41    use std::panic::{RefUnwindSafe, UnwindSafe};
42
43    use static_assertions::assert_impl_all;
44
45    use super::*;
46
47    assert_impl_all!(EfficiencyClass: UnwindSafe, RefUnwindSafe);
48}