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
impl ExternalCpuDomain
Sourcepub fn new(
id: CpuDomainId,
placement: ResolvedCpuPlacement,
executor: Arc<dyn CpuDomainExecutor>,
thread_budget: NonZeroUsize,
placement_guarantee: CpuPlacementGuarantee,
) -> Result<Self, ExternalCpuDomainError>
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.
Sourcepub fn id(&self) -> CpuDomainId
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;Sourcepub fn placement(&self) -> &ResolvedCpuPlacement
pub fn placement(&self) -> &ResolvedCpuPlacement
Return the declared resolved placement.
§Examples
use tenferro_cpu::{ExternalCpuDomain, ResolvedCpuPlacement};
let _placement: fn(&ExternalCpuDomain) -> &ResolvedCpuPlacement =
ExternalCpuDomain::placement;Sourcepub fn cpus(&self) -> &CpuSet
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;Sourcepub fn thread_budget(&self) -> NonZeroUsize
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;Sourcepub fn placement_guarantee(&self) -> CpuPlacementGuarantee
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;Sourcepub fn ownership(&self) -> CpuDomainOwnership
pub fn ownership(&self) -> CpuDomainOwnership
Return the external ownership diagnostic.
§Examples
use tenferro_cpu::{CpuDomainOwnership, ExternalCpuDomain};
let _ownership: fn(&ExternalCpuDomain) -> CpuDomainOwnership =
ExternalCpuDomain::ownership;Sourcepub fn executor_capabilities(&self) -> CpuDomainExecutorCapabilities
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§
Auto Trait Implementations§
impl Freeze for ExternalCpuDomain
impl !RefUnwindSafe for ExternalCpuDomain
impl Send for ExternalCpuDomain
impl Sync for ExternalCpuDomain
impl Unpin for ExternalCpuDomain
impl UnsafeUnpin for ExternalCpuDomain
impl !UnwindSafe for ExternalCpuDomain
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
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>
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>
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