Skip to main content

BroadcastJoin

Struct BroadcastJoin 

Source
pub struct BroadcastJoin<'pool, 'fork, F>
where F: Fn(usize, usize) + Sync,
{ /* private fields */ }
Expand description

A synchronization guard that waits for all threads to finish the broadcasted closure.

The lifecycle is keyed on the pool’s exclusivity:

  • On CallerExclusivity::Exclusive pools the closure is dispatched at construction: the workers start immediately, the caller can overlap its own work, poll is_complete, and join (or Drop) waits for completion.
  • On CallerExclusivity::Inclusive pools the dispatch is deferred to join (or Drop), where the calling thread contributes its own slice of the work.

The closure is borrowed rather than owned, so its address stays stable while worker threads hold a pointer to it, and the guard itself remains freely movable.

Implementations§

Source§

impl<'pool, 'fork, F> BroadcastJoin<'pool, 'fork, F>
where F: Fn(usize, usize) + Sync,

Source

pub fn generation(&self) -> Option<usize>

The generation token of this broadcast; always odd once dispatched.

Source

pub fn is_complete(&self) -> bool

True once the dispatched generation has fully completed on all threads.

A true result also guarantees visibility of every contributor’s writes. On Inclusive pools this can only turn true once join contributes the calling thread’s slice, so the poll-then-join pattern is reserved for Exclusive pools.

Source

pub fn join(&mut self)

Wait for all threads to complete their work. On Inclusive pools this dispatches the work first and contributes the caller’s slice. Idempotent - subsequent calls are no-ops.

Trait Implementations§

Source§

impl<F> Drop for BroadcastJoin<'_, '_, F>
where F: Fn(usize, usize) + Sync,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'pool, 'fork, F> !UnwindSafe for BroadcastJoin<'pool, 'fork, F>

§

impl<'pool, 'fork, F> Freeze for BroadcastJoin<'pool, 'fork, F>

§

impl<'pool, 'fork, F> RefUnwindSafe for BroadcastJoin<'pool, 'fork, F>

§

impl<'pool, 'fork, F> Send for BroadcastJoin<'pool, 'fork, F>
where &'fork F: Send,

§

impl<'pool, 'fork, F> Sync for BroadcastJoin<'pool, 'fork, F>
where &'fork F: Sync,

§

impl<'pool, 'fork, F> Unpin for BroadcastJoin<'pool, 'fork, F>
where &'fork F: Unpin,

§

impl<'pool, 'fork, F> UnsafeUnpin for BroadcastJoin<'pool, 'fork, F>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.