Struct dispatch::Group

source ·
pub struct Group { /* private fields */ }
Expand description

A Grand Central Dispatch group.

A Group is a mechanism for grouping closures and monitoring them. This allows for aggregate synchronization, so you can track when all the closures complete, even if they are running on different queues.

Implementations§

source§

impl Group

source

pub fn create() -> Group

Creates a new dispatch Group.

source

pub fn enter(&self) -> GroupGuard

Indicates that a closure has entered self, and increments the current count of outstanding tasks. Returns a GroupGuard that should be dropped when the closure leaves self, decrementing the count.

source

pub fn exec_async<F>(&self, queue: &Queue, work: F)where F: 'static + Send + FnOnce(),

Submits a closure asynchronously to the given Queue and associates it with self.

source

pub fn notify<F>(&self, queue: &Queue, work: F)where F: 'static + Send + FnOnce(),

Schedules a closure to be submitted to the given Queue when all tasks associated with self have completed. If self is empty, the closure is submitted immediately.

source

pub fn wait(&self)

Waits synchronously for all tasks associated with self to complete.

source

pub fn wait_timeout(&self, timeout: Duration) -> Result<(), WaitTimeout>

Waits for all tasks associated with self to complete within the specified duration. Returns true if the tasks completed or false if the timeout elapsed.

source

pub fn is_empty(&self) -> bool

Returns whether self is currently empty.

Trait Implementations§

source§

impl Clone for Group

source§

fn clone(&self) -> Self

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 Debug for Group

source§

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

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

impl Drop for Group

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for Group

source§

impl Sync for Group

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.