thread_tree

Struct ThreadTreeCtx

Source
pub struct ThreadTreeCtx<'a> { /* private fields */ }
Expand description

A level-specific handle to the thread tree, that can be used to inject jobs.

See ThreadTree::top() for more information.

Implementations§

Source§

impl ThreadTreeCtx<'_>

Source

pub fn is_parallel(&self) -> bool

Return true if this level will parallelize in join (or if we are at the bottom of the tree)

Source

pub fn join<A, B, RA, RB>(&self, a: A, b: B) -> (RA, RB)
where A: FnOnce(ThreadTreeCtx<'_>) -> RA + Send, B: FnOnce(ThreadTreeCtx<'_>) -> RB + Send, RA: Send, RB: Send,

Branch out and run a and b simultaneously and return their results jointly.

Job a runs on the current thread while b runs on the sibling thread; each is passed a lower level of the thread tree. If the bottom of the tree is reached, where no sibling threads are available, both a and b run on the current thread.

If either a or b panics, the panic is propagated here. If both jobs are executing, the panic will not propagate until after both jobs have finished.

Warning: You must not .join() into the same tree from nested jobs. Nested jobs must be spawned using the context that each job receives as the first parameter.

Source

pub fn join3l<A, RA>(&self, a: &A) -> ((RA, RA), RA)
where A: Fn(ThreadTreeCtx<'_>, usize) -> RA + Sync, RA: Send,

Branch out twice and join, running three different jobs

Branches twice on the left side and once on the right. The closure is called with corresponding thread tree context and an index in 0..3 for the job.

Source

pub fn join3r<A, RA>(&self, a: &A) -> (RA, (RA, RA))
where A: Fn(ThreadTreeCtx<'_>, usize) -> RA + Sync, RA: Send,

Branch out twice and join, running three different jobs

Branches once on the right side and twice on the right. The closure is called with corresponding thread tree context and an index in 0..3 for the job.

Source

pub fn join4<A, RA>(&self, a: &A) -> ((RA, RA), (RA, RA))
where A: Fn(ThreadTreeCtx<'_>, usize) -> RA + Sync, RA: Send,

Branch out twice and join, running four different jobs.

Branches twice on each side. The closure is called with corresponding thread tree context and an index in 0..4 for the job.

Trait Implementations§

Source§

impl<'a> Clone for ThreadTreeCtx<'a>

Source§

fn clone(&self) -> ThreadTreeCtx<'a>

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<'a> Debug for ThreadTreeCtx<'a>

Source§

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

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

impl<'a> Copy for ThreadTreeCtx<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ThreadTreeCtx<'a>

§

impl<'a> RefUnwindSafe for ThreadTreeCtx<'a>

§

impl<'a> !Send for ThreadTreeCtx<'a>

§

impl<'a> !Sync for ThreadTreeCtx<'a>

§

impl<'a> Unpin for ThreadTreeCtx<'a>

§

impl<'a> UnwindSafe for ThreadTreeCtx<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
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> ToOwned for T
where T: Clone,

Source§

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

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.