pub enum ResolvedAffinity {
None,
Fixed(BTreeSet<usize>),
Random {
from: BTreeSet<usize>,
count: usize,
},
SingleCpu(usize),
}Expand description
Resolved CPU affinity for a worker process.
Created from AffinityIntent at runtime based on topology and
cpuset assignments. Variant names track AffinityIntent where the
same shape exists pre/post-resolution; payload presence
distinguishes intent from concrete CPU id(s). See the
AffinityIntent type doc for the full pre/post mapping table.
Variants§
None
No affinity constraint.
Fixed(BTreeSet<usize>)
Pin to a specific set of CPUs.
Random
Pin to count randomly-chosen CPUs from from.
countmust be> 0; zero is rejected at resolve time (previously it coerced silently to 1 and masked caller bugs).count > from.len()is clamped tofrom.len()— asking for more CPUs than the pool contains is a topology fact, not a caller error.fromempty withcount > 0is a caller bug:resolve_affinitybails (an unsatisfiable sample request would otherwise produce an emptysched_setaffinitymask that the kernel rejects withEINVAL). The resolution step that produces this variant — seecrate::scenario::resolve_affinity_for_cgroup— bails on empty pools before construction; no silent fallback. Direct constructor callers (e.g. test fixtures) must do the same: useResolvedAffinity::Nonefor “no affinity constraint”, neverRandom { from: empty, count: > 0 }.
SingleCpu(usize)
Pin to a single CPU.
Implementations§
Source§impl ResolvedAffinity
impl ResolvedAffinity
Sourcepub fn fixed(cpus: impl IntoIterator<Item = usize>) -> Self
pub fn fixed(cpus: impl IntoIterator<Item = usize>) -> Self
Construct a ResolvedAffinity::Fixed from any iterator over
CPU ids. Mirrors AffinityIntent::exact.
Sourcepub fn random(from: impl IntoIterator<Item = usize>, count: usize) -> Self
pub fn random(from: impl IntoIterator<Item = usize>, count: usize) -> Self
Construct a ResolvedAffinity::Random from a pool iterator
and a sample count. Mirrors AffinityIntent::random_subset.
Sourcepub const fn single_cpu(cpu: usize) -> Self
pub const fn single_cpu(cpu: usize) -> Self
Construct a ResolvedAffinity::SingleCpu.
Trait Implementations§
Source§impl Clone for ResolvedAffinity
impl Clone for ResolvedAffinity
Source§fn clone(&self) -> ResolvedAffinity
fn clone(&self) -> ResolvedAffinity
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ResolvedAffinity
impl Debug for ResolvedAffinity
Source§impl Default for ResolvedAffinity
impl Default for ResolvedAffinity
Source§fn default() -> ResolvedAffinity
fn default() -> ResolvedAffinity
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ResolvedAffinity
impl<'de> Deserialize<'de> for ResolvedAffinity
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Hash for ResolvedAffinity
impl Hash for ResolvedAffinity
Source§impl PartialEq for ResolvedAffinity
impl PartialEq for ResolvedAffinity
Source§impl Serialize for ResolvedAffinity
impl Serialize for ResolvedAffinity
impl Eq for ResolvedAffinity
impl StructuralPartialEq for ResolvedAffinity
Auto Trait Implementations§
impl Freeze for ResolvedAffinity
impl RefUnwindSafe for ResolvedAffinity
impl Send for ResolvedAffinity
impl Sync for ResolvedAffinity
impl Unpin for ResolvedAffinity
impl UnwindSafe for ResolvedAffinity
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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