pub struct CpuSet(/* private fields */);
Expand description
Used to specify a set of permitted CPUs on which
executors created by a
LocalExecutorPoolBuilder
are run.
Please see the documentation for PoolPlacement
variants to
understand how CpuSet
restrictions apply to each variant. CPUs are
identified via their CpuLocation
.
Implementations§
source§impl CpuSet
impl CpuSet
sourcepub fn online() -> Result<Self, ()>
pub fn online() -> Result<Self, ()>
Creates a CpuSet
representing all CPUs that are online.
The function will return an Err
if the hardware topology could not
be obtained from this machine.
sourcepub fn filter<F>(self, f: F) -> Self
pub fn filter<F>(self, f: F) -> Self
This method can be used to restrict the CPUs held by CpuSet
. The
resulting CpuSet
will only include CpuLocation
s for which the
provided closure returns true
. Note that each call to filter
will use as input the set of CPUs previously selected (i.e. the set is
not reset on each call).
use glommio::CpuSet;
// get CPUs on NUMA node 0
let cpus = CpuSet::online()
.expect("Err: please file an issue with glommio")
.filter(|l| l.numa_node == 0);
println!("The filtered CPUs are: {cpus:#?}");
sourcepub fn iter(&self) -> Iter<'_, CpuLocation>
pub fn iter(&self) -> Iter<'_, CpuLocation>
An iterator visiting all CpuLocation
s in this CpuSet in arbitrary
order.
sourcepub fn contains(&self, value: &CpuLocation) -> bool
pub fn contains(&self, value: &CpuLocation) -> bool
Returns true
if the CpuSet
contains a CpuLocation
.
sourcepub fn difference<'a>(
&'a self,
other: &'a Self
) -> Difference<'a, CpuLocation, RandomState>
pub fn difference<'a>( &'a self, other: &'a Self ) -> Difference<'a, CpuLocation, RandomState>
Visits the CpuLocation
s representing the difference, i.e., the
values that are in self but not in the other.
sourcepub fn intersection<'a>(
&'a self,
other: &'a Self
) -> Intersection<'a, CpuLocation, RandomState>
pub fn intersection<'a>( &'a self, other: &'a Self ) -> Intersection<'a, CpuLocation, RandomState>
Visits the CpuLocation
s representing the intersection, i.e., the
values that are both in self and other.
sourcepub fn is_disjoint(&self, other: &Self) -> bool
pub fn is_disjoint(&self, other: &Self) -> bool
Returns true if self has no CpuLocation
s in common with the other.
This is equivalent to checking for an empty intersection.
sourcepub fn is_subset(&self, other: &Self) -> bool
pub fn is_subset(&self, other: &Self) -> bool
Returns true if this CpuSet
is a subset of another, i.e., other
contains at least all the values in self.
sourcepub fn is_superset(&self, other: &Self) -> bool
pub fn is_superset(&self, other: &Self) -> bool
Returns true if this CpuSet
is a superset of another, i.e., self
contains at least all the values in the other.
sourcepub fn symmetric_difference<'a>(
&'a self,
other: &'a Self
) -> SymmetricDifference<'a, CpuLocation, RandomState>
pub fn symmetric_difference<'a>( &'a self, other: &'a Self ) -> SymmetricDifference<'a, CpuLocation, RandomState>
Visits the CpuLocation
s representing the symmetric difference, i.e.,
the values that are in self or in other but not in both.
sourcepub fn union<'a>(
&'a self,
other: &'a Self
) -> Union<'a, CpuLocation, RandomState>
pub fn union<'a>( &'a self, other: &'a Self ) -> Union<'a, CpuLocation, RandomState>
Visits the CpuLocation
s representing the union, i.e., all the values
in self or other, without duplicates.