pub enum Par<'team> {
Seq,
Rayon(NonZeroUsize),
// some variants omitted
}Expand description
determines the parallelization configuration, and carries the right to execute with it
Par is neither Copy nor Clone: a Team owns exclusive authority over reserved
threads, so a duplicate could hand the same threads to two concurrent children. Every
function that runs work takes Par by value; a caller that needs another phase lends the
parallelism with Par::reborrow, and concurrent children are created by splitting
(see utils::thread::split), never by copying. Queries that only need the size (workspace
requirements, thresholds) use ParShape or Par::degree.
use faer::{Par, ParShape};
// sizes are plain values
fn is_copy<T: Copy>() {}
is_copy::<ParShape>();
// phases lend, they do not copy
fn phase(_: Par<'_>) {}
let mut par = Par::Seq;
phase(par.reborrow());
phase(par);Not Copy:
fn is_copy<T: Copy>() {}
is_copy::<faer::Par<'static>>();Not Clone:
fn is_clone<T: Clone>() {}
is_clone::<faer::Par<'static>>();A phase that takes the parallelism consumes it:
fn phase(_: faer::Par<'_>) {}
let par = faer::Par::Seq;
phase(par);
phase(par);Concurrent children cannot both use the parent:
fn phase(_: faer::Par<'_>) {}
let par = faer::Par::Seq;
faer::utils::thread::join_raw(|_| phase(par), |_| phase(par), faer::Par::Seq);Variants§
Seq
sequential, non portable across different platforms
Rayon(NonZeroUsize)
parallelized using the global rayon threadpool, non portable across different platforms
Implementations§
Source§impl Par<'_>
impl Par<'_>
Sourcepub fn reborrow(&mut self) -> Par<'_>
pub fn reborrow(&mut self) -> Par<'_>
lends the parallelism for one phase. The parent is exclusively borrowed and unusable while the lent value lives, so a phase sequence never holds the authority twice.
Sourcepub fn shape(&self) -> ParShape
pub fn shape(&self) -> ParShape
the shape of this parallelism, without the right to execute with it
Trait Implementations§
Auto Trait Implementations§
impl<'team> Freeze for Par<'team>
impl<'team> RefUnwindSafe for Par<'team>
impl<'team> Send for Par<'team>
impl<'team> Sync for Par<'team>
impl<'team> Unpin for Par<'team>
impl<'team> UnsafeUnpin for Par<'team>
impl<'team> UnwindSafe for Par<'team>
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> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
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