Skip to main content

ExternalCpuDomain

Struct ExternalCpuDomain 

Source
pub struct ExternalCpuDomain { /* private fields */ }
Expand description

Caller-supplied descriptor for one externally managed CPU resource domain.

The descriptor retains the supplied executor without replacing its pool or changing its affinity claim. Registration and process-CPU-set validation are performed later by crate::CpuBackend.

§Examples

use std::num::NonZeroUsize;
use std::sync::Arc;
use tenferro_cpu::{
    CpuContext, CpuDomainOwnership, CpuId, CpuPlacementGuarantee, CpuSet,
    ExternalCpuDomain, ResolvedCpuPlacement,
};
use tenferro_tensor::CpuDomainId;

let domain = ExternalCpuDomain::new(
    CpuDomainId::new(7),
    ResolvedCpuPlacement::AllAllowed {
        cpus: CpuSet::new([CpuId::new(0)])?,
    },
    Arc::new(CpuContext::with_threads(1)?),
    NonZeroUsize::new(1).unwrap(),
    CpuPlacementGuarantee::AdvisoryDeclared,
)?;
assert_eq!(domain.ownership(), CpuDomainOwnership::ExternalManaged);

Implementations§

Source§

impl ExternalCpuDomain

Source

pub fn new( id: CpuDomainId, placement: ResolvedCpuPlacement, executor: Arc<dyn CpuDomainExecutor>, thread_budget: NonZeroUsize, placement_guarantee: CpuPlacementGuarantee, ) -> Result<Self, ExternalCpuDomainError>

Construct one externally managed CPU resource-domain descriptor.

The executor is retained for the complete descriptor lifetime. Exact and advisory placement values remain caller declarations and do not alter the executor’s affinity capability.

§Examples
use std::num::NonZeroUsize;
use std::sync::Arc;
use tenferro_cpu::{
    CpuContext, CpuId, CpuPlacementGuarantee, CpuSet, ExternalCpuDomain,
    ResolvedCpuPlacement,
};
use tenferro_tensor::CpuDomainId;

let domain = ExternalCpuDomain::new(
    CpuDomainId::new(3),
    ResolvedCpuPlacement::AllAllowed {
        cpus: CpuSet::new([CpuId::new(0)])?,
    },
    Arc::new(CpuContext::with_threads(1)?),
    NonZeroUsize::new(1).unwrap(),
    CpuPlacementGuarantee::ExactDeclared,
)?;
assert_eq!(domain.id(), CpuDomainId::new(3));
§Errors

Returns ExternalCpuDomainError::EmptyPlacementCpuSet for an empty resolved CPU set, ExternalCpuDomainError::ZeroExecutorWorkers when the executor reports no workers, or ExternalCpuDomainError::ThreadBudgetExceedsWorkerCount when thread_budget is greater than the executor’s worker count.

Source

pub fn id(&self) -> CpuDomainId

Return the caller-stable identity of this CPU domain.

§Examples
use tenferro_cpu::ExternalCpuDomain;
use tenferro_tensor::CpuDomainId;

let _id: fn(&ExternalCpuDomain) -> CpuDomainId = ExternalCpuDomain::id;
Source

pub fn placement(&self) -> &ResolvedCpuPlacement

Return the declared resolved placement.

§Examples
use tenferro_cpu::{ExternalCpuDomain, ResolvedCpuPlacement};

let _placement: fn(&ExternalCpuDomain) -> &ResolvedCpuPlacement =
    ExternalCpuDomain::placement;
Source

pub fn cpus(&self) -> &CpuSet

Return the logical CPUs declared for this domain.

§Examples
use tenferro_cpu::{CpuSet, ExternalCpuDomain};

let _cpus: fn(&ExternalCpuDomain) -> &CpuSet = ExternalCpuDomain::cpus;
Source

pub fn thread_budget(&self) -> NonZeroUsize

Return the nonzero thread budget requested for tenferro work.

§Examples
use std::num::NonZeroUsize;
use tenferro_cpu::ExternalCpuDomain;

let _budget: fn(&ExternalCpuDomain) -> NonZeroUsize =
    ExternalCpuDomain::thread_budget;
Source

pub fn placement_guarantee(&self) -> CpuPlacementGuarantee

Return whether placement is an exact or advisory declaration.

§Examples
use tenferro_cpu::{CpuPlacementGuarantee, ExternalCpuDomain};

let _guarantee: fn(&ExternalCpuDomain) -> CpuPlacementGuarantee =
    ExternalCpuDomain::placement_guarantee;
Source

pub fn ownership(&self) -> CpuDomainOwnership

Return the external ownership diagnostic.

§Examples
use tenferro_cpu::{CpuDomainOwnership, ExternalCpuDomain};

let _ownership: fn(&ExternalCpuDomain) -> CpuDomainOwnership =
    ExternalCpuDomain::ownership;
Source

pub fn executor_capabilities(&self) -> CpuDomainExecutorCapabilities

Return the supplied executor’s immutable capability descriptor.

§Examples
use tenferro_cpu::{CpuDomainExecutorCapabilities, ExternalCpuDomain};

let _capabilities: fn(&ExternalCpuDomain) -> CpuDomainExecutorCapabilities =
    ExternalCpuDomain::executor_capabilities;

Trait Implementations§

Source§

impl Debug for ExternalCpuDomain

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

Source§

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>,

Source§

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.
§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,

§

impl<T> MaybeSync for T
where T: Sync,