dispatch_barrier_async 的注意是事项
使用 dispatch_barrier_async ,该函数只能搭配自定义并行队列 dispatch_queue_t 使用。不能使用: dispatch_get_global_queue ,否则 dispatch_barrier_async 的作用会和 dispatch_async 的作用一模一样。
系统的解释
/*!
- @functiongroup Dispatch Barrier API
- The dispatch barrier API is a mechanism for submitting barrier blocks to a
- dispatch queue, analogous to the dispatch_async()/dispatch_sync() API.
- It enables the implementation of efficient reader/writer schemes.
- Barrier blocks only behave specially when submitted to queues created with
- the DISPATCH_QUEUE_CONCURRENT attribute; on such a queue, a barrier block
- will not run until all blocks submitted to the queue earlier have completed,
- and any blocks submitted to the queue after a barrier block will not run
- until the barrier block has completed.
- When submitted to a a global queue or to a queue not created with the
- DISPATCH_QUEUE_CONCURRENT attribute, barrier blocks behave identically to
- blocks submitted with the dispatch_async()/dispatch_sync() API.
*/