Dispatch Group
A group of tasks that you monitor as a single unit.
Overview
Groups allow you to aggregate a set of tasks and synchronize behaviors on the group. You attach multiple blocks to a group and schedule them for asynchronous execution on the same queue or different queues. When all blocks finish executing, the group executes its completion handler. You can also wait synchronously for all blocks in the group to finish executing.
用于非dispatch_group_async(group, queue)方式添加的工作组任务;
Schedules a block object to be submitted to a queue when a group of previously submitted block objects have completed.
Waits synchronously for the previously submitted block objects to finish; returns if the blocks do not complete before the specified timeout period has elapsed.
Updating the Group Manually
dispatch_group_enter
Explicitly indicates that a block has entered the group.
dispatch_group_leave
Explicitly indicates that a block in the group finished executing.
https://developer.apple.com/documentation/dispatch/dispatch_group?language=occ