Struct glommio::CpuSet

source ·
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

source

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.

source

pub fn filter<F>(self, f: F) -> Self
where F: FnMut(&CpuLocation) -> bool,

This method can be used to restrict the CPUs held by CpuSet. The resulting CpuSet will only include CpuLocations 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:#?}");
source

pub fn is_empty(&self) -> bool

Checks whether the CpuSet is empty.

source

pub fn iter(&self) -> Iter<'_, CpuLocation>

An iterator visiting all CpuLocations in this CpuSet in arbitrary order.

source

pub fn len(&self) -> usize

Returns the number of CPUs included in the CpuSet.

source

pub fn contains(&self, value: &CpuLocation) -> bool

Returns true if the CpuSet contains a CpuLocation.

source

pub fn difference<'a>( &'a self, other: &'a Self ) -> Difference<'a, CpuLocation, RandomState>

Visits the CpuLocations representing the difference, i.e., the values that are in self but not in the other.

source

pub fn intersection<'a>( &'a self, other: &'a Self ) -> Intersection<'a, CpuLocation, RandomState>

Visits the CpuLocations representing the intersection, i.e., the values that are both in self and other.

source

pub fn is_disjoint(&self, other: &Self) -> bool

Returns true if self has no CpuLocations in common with the other. This is equivalent to checking for an empty intersection.

source

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.

source

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.

source

pub fn symmetric_difference<'a>( &'a self, other: &'a Self ) -> SymmetricDifference<'a, CpuLocation, RandomState>

Visits the CpuLocations representing the symmetric difference, i.e., the values that are in self or in other but not in both.

source

pub fn union<'a>( &'a self, other: &'a Self ) -> Union<'a, CpuLocation, RandomState>

Visits the CpuLocations representing the union, i.e., all the values in self or other, without duplicates.

Trait Implementations§

source§

impl Clone for CpuSet

source§

fn clone(&self) -> CpuSet

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CpuSet

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FromIterator<CpuLocation> for CpuSet

source§

fn from_iter<I: IntoIterator<Item = CpuLocation>>(cpus: I) -> Self

Creates a value from an iterator. Read more
source§

impl Hash for CpuSet

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a> IntoIterator for &'a CpuSet

§

type Item = &'a CpuLocation

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, CpuLocation>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Iter<'a, CpuLocation>

Creates an iterator from a value. Read more
source§

impl IntoIterator for CpuSet

§

type Item = CpuLocation

The type of the elements being iterated over.
§

type IntoIter = IntoIter<CpuLocation>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> IntoIter<CpuLocation>

Creates an iterator from a value. Read more
source§

impl PartialEq for CpuSet

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for CpuSet

Auto Trait Implementations§

§

impl Freeze for CpuSet

§

impl RefUnwindSafe for CpuSet

§

impl Send for CpuSet

§

impl Sync for CpuSet

§

impl Unpin for CpuSet

§

impl UnwindSafe for CpuSet

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CallHasher for T
where T: Hash + ?Sized,

source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more