Contents

dispatch_group_wait

Waits synchronously for the previously submitted block objects to finish; returns if the blocks do not complete before the specified timeout period has elapsed.

Declaration

extern intptr_t dispatch_group_wait(dispatch_group_t group, dispatch_time_t timeout);

Parameters

Return Value

Returns zero on success (all blocks associated with the group completed before the specified timeout) or non-zero on error (timeout occurred).

Discussion

This function waits for the completion of the blocks associated with the given dispatch group and returns when either all blocks have completed or the specified timeout has elapsed. When a timeout occurs, the group is restored to its original state.

This function returns immediately if the dispatch group is empty (there are no blocks associated with the group).

After the successful return of this function, the dispatch group is empty, and can be reused for additional blocks. See dispatch_group_async for more information.

If your app isn’t using ARC, you should call dispatch_release on a dispatch group when it’s no longer needed.