pub struct ProcessorSet { /* private fields */ }Expand description
A set of logical processors, correctly spanning more than one processor group.
A Windows thread’s affinity is a GROUP_AFFINITY – one group and a bitmask
within it – because a group is a hard boundary: no single mask can name
processors in two different groups. A type that silently flattened to one
64-bit mask would misrepresent any topology wider than one group, which is
exactly the class of bug this type exists to prevent. ProcessorSet keeps
each group’s mask separate instead.
Implementations§
Source§impl ProcessorSet
impl ProcessorSet
Sourcepub fn from_group_mask(group: u16, mask: usize) -> Self
pub fn from_group_mask(group: u16, mask: usize) -> Self
A set naming every bit set in mask within group.
Sourcepub fn can_represent(number: u8) -> bool
pub fn can_represent(number: u8) -> bool
Whether a processor number fits this platform’s group width.
A ProcessorSet holds one bit per processor in a usize, so the
ceiling is usize::BITS – 64 on x86-64, 32 on i686-pc-windows-msvc.
ProcessorId::number is a u8 and its field is public, so a caller can
build an id this set cannot hold; Self::insert asserts on one, and
this is how a caller asks before rather than being aborted.
Sourcepub fn insert(&mut self, group: u16, number: u8)
pub fn insert(&mut self, group: u16, number: u8)
Add number within group to the set.
§Panics
Panics if number is MAX_PROCESSORS_PER_GROUP or greater: a
processor group cannot hold more processors than a mask has bits.
Self::can_represent is how a caller holding a publicly-constructed
crate::ProcessorId asks first – the panic is for a caller building
a set it controls, not a way to reject a query’s argument.
Sourcepub fn contains(&self, group: u16, number: u8) -> bool
pub fn contains(&self, group: u16, number: u8) -> bool
Whether group/number is a member of this set.
Sourcepub fn group_mask(&self, group: u16) -> usize
pub fn group_mask(&self, group: u16) -> usize
The raw mask for a single group, or 0 if the group has no members here.
Sourcepub fn group_masks(&self) -> impl Iterator<Item = (u16, usize)> + '_
pub fn group_masks(&self) -> impl Iterator<Item = (u16, usize)> + '_
Iterate over (group, mask) pairs, one per group with any member here,
in ascending group order.
Sourcepub fn iter(&self) -> impl Iterator<Item = (u16, u8)> + '_
pub fn iter(&self) -> impl Iterator<Item = (u16, u8)> + '_
Iterate over every (group, number) member, in ascending order.
Sourcepub fn intersection(&self, other: &Self) -> Self
pub fn intersection(&self, other: &Self) -> Self
The set of processors present in both self and other.
Sourcepub fn union(&self, other: &Self) -> Self
pub fn union(&self, other: &Self) -> Self
The set of processors present in either self or other.
Sourcepub fn is_disjoint(&self, other: &Self) -> bool
pub fn is_disjoint(&self, other: &Self) -> bool
Whether self and other share no processors.
Sourcepub fn is_subset(&self, other: &Self) -> bool
pub fn is_subset(&self, other: &Self) -> bool
Whether every processor in self is also in other.
This is the comparison the granularity order is built on (M2+.2): inclusion is checkable against the memberships the platform actually reported, where a firmware level number is only asserted. The empty set is a subset of everything, which follows from the definition and is not a special case.
Trait Implementations§
Source§impl Clone for ProcessorSet
impl Clone for ProcessorSet
Source§fn clone(&self) -> ProcessorSet
fn clone(&self) -> ProcessorSet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProcessorSet
impl Debug for ProcessorSet
Source§impl Default for ProcessorSet
impl Default for ProcessorSet
Source§fn default() -> ProcessorSet
fn default() -> ProcessorSet
Source§impl<'de> Deserialize<'de> for ProcessorSet
Available on crate feature serde only.
impl<'de> Deserialize<'de> for ProcessorSet
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for ProcessorSet
Source§impl FromIterator<(u16, u8)> for ProcessorSet
impl FromIterator<(u16, u8)> for ProcessorSet
Source§impl PartialEq for ProcessorSet
impl PartialEq for ProcessorSet
Source§impl Serialize for ProcessorSet
Available on crate feature serde only.
impl Serialize for ProcessorSet
serde only.