pub struct Domain { /* private fields */ }Expand description
A P0 execution domain.
Domain::sequential creates domain zero with one worker and no Rayon pool.
At most one coarse operation may be admitted at a time; Domain::try_admit
returns DomainBusy immediately instead of waiting when another operation
owns the domain.
§Example
use hataori::{Domain, DomainBusy};
let domain = Domain::sequential();
let admission = domain.try_admit().unwrap();
assert_eq!(domain.try_admit().unwrap_err(), DomainBusy);
drop(admission);
assert!(domain.try_admit().is_ok());Implementations§
Source§impl Domain
impl Domain
Sourcepub fn sequential() -> Self
pub fn sequential() -> Self
Creates the P0 sequential domain: ID zero, one worker, and no running operation.
Sourcepub const fn worker_count(&self) -> usize
pub const fn worker_count(&self) -> usize
Returns the declared worker count.
Sourcepub fn try_admit(&self) -> Result<DomainAdmission<'_>, DomainBusy>
pub fn try_admit(&self) -> Result<DomainAdmission<'_>, DomainBusy>
Attempts to admit one coarse operation without waiting.
Sourcepub fn managed(
cpu_set: Vec<usize>,
worker_count: usize,
) -> Result<Self, DomainBuildError>
pub fn managed( cpu_set: Vec<usize>, worker_count: usize, ) -> Result<Self, DomainBuildError>
Creates and owns a Rayon pool, verifying worker affinity on Linux.
Sourcepub fn external(
pool: Arc<ThreadPool>,
declared_cpu_set: Vec<usize>,
worker_count: usize,
) -> Result<Self, DomainBuildError>
pub fn external( pool: Arc<ThreadPool>, declared_cpu_set: Vec<usize>, worker_count: usize, ) -> Result<Self, DomainBuildError>
Uses a caller-owned Rayon pool without changing its worker affinity or shutting it down when this domain is dropped.
Sourcepub fn cpu_set(&self) -> Option<&[usize]>
pub fn cpu_set(&self) -> Option<&[usize]>
Returns the declared or verified CPU set, when this domain has a pool.
Sourcepub fn pool_ownership(&self) -> Option<PoolOwnership>
pub fn pool_ownership(&self) -> Option<PoolOwnership>
Returns the pool ownership mode, when this domain has a pool.
Sourcepub fn placement_status(&self) -> Option<PlacementStatus>
pub fn placement_status(&self) -> Option<PlacementStatus>
Returns the placement status, when this domain has a pool.
Sourcepub fn rayon_pool_handle(&self) -> Option<Arc<ThreadPool>>
pub fn rayon_pool_handle(&self) -> Option<Arc<ThreadPool>>
Clones the Rayon pool handle associated with this domain, when present.
This grants no domain admission. Submitting work directly to the returned
pool bypasses Hataori scheduling; integration adapters must enter through
an already admitted LocalMode::Inner callback.
§Examples
use hataori::Domain;
use std::sync::Arc;
let pool = Arc::new(rayon::ThreadPoolBuilder::new().num_threads(1).build().unwrap());
let domain = Domain::external(Arc::clone(&pool), vec![0], 1).unwrap();
assert!(Arc::ptr_eq(&pool, &domain.rayon_pool_handle().unwrap()));Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Domain
impl !RefUnwindSafe for Domain
impl !UnwindSafe for Domain
impl Send for Domain
impl Sync for Domain
impl Unpin for Domain
impl UnsafeUnpin for Domain
Blanket Implementations§
§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
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
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
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