pub struct JobGroup { /* private fields */ }Expand description
Thread-safe counter-based completion primitive for grouped jobs.
A JobGroup starts with zero pending jobs. Call add() before submitting work, then call done() once per completed job. wait() blocks until the pending count reaches zero.
Typical usage pattern: 1. add(N) 2. submit N tasks 3. each task calls done() on completion 4. wait() to join the group
Implementations§
Source§impl JobGroup
impl JobGroup
Sourcepub fn add(&mut self, n: usize)
pub fn add(&mut self, n: usize)
Increment the number of pending jobs.
@param n Number of jobs to add to the group.
Sourcepub fn done(&mut self)
pub fn done(&mut self)
Mark one pending job as completed.
When the pending count reaches zero, all waiters are notified.
@note done() calls must be balanced with prior add() calls.
Trait Implementations§
impl Send for JobGroup
Auto Trait Implementations§
impl !Sync for JobGroup
impl Freeze for JobGroup
impl RefUnwindSafe for JobGroup
impl Unpin for JobGroup
impl UnsafeUnpin for JobGroup
impl UnwindSafe for JobGroup
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
Mutably borrows from an owned value. Read more