Is dispatch_sync(dispatch_get_global_queue(xxx), task) sync or async

后端 未结 2 1667
傲寒
傲寒 2021-01-03 03:18

As Apple\'s document says, dispatch_get_global_queue() is a concurrent queue, and dispatch_sync is something meaning serial.Then the tasks are processed async or sync?

2条回答
  •  無奈伤痛
    2021-01-03 03:59

    Apple Doc says

    dispatch_get_global_queue

    Returns a well-known global concurrent queue of a given priority level.

    dispatch_queue_t dispatch_get_global_queue( long priority, unsigned long flags);

    Parameters

    priority The priority of the queue being retrieved. For a list of possible values, see “dispatch_queue_priority_t”. flags This value is reserved for future use. You should always pass 0. Return Value Returns the requested global queue.

    Discussion

    The well-known global concurrent queues cannot be modified. Calls to dispatch_suspend, dispatch_resume, dispatch_set_context, and the like have no effect when used with queues returned by this function.

    Blocks submitted to these global concurrent queues may be executed concurrently with respect to each other.

    Availability Available in iOS 4.0 and later. Declared In dispatch/queue.h

    In the Discussion they have said that-> 'blocks submitted MAY be executed concurrently wrt each other.'

    So Tasks may be processed Async with each other.

提交回复
热议问题