Submits a barrier block object for execution and waits until that block completes.
- iOS 4.3+
- macOS 10.7+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
The dispatch queue on which to execute the barrier block. This parameter cannot be
The barrier block to be executed. This parameter cannot be
Submits a barrier block to a dispatch queue for synchronous execution. Unlike
dispatch, this function does not return until the barrier block has finished. Calling this function and targeting the current queue results in deadlock.
When the barrier block reaches the front of a private concurrent queue, it is not executed immediately. Instead, the queue waits until its currently executing blocks finish executing. At that point, the queue executes the barrier block by itself. Any blocks submitted after the barrier block are not executed until the barrier block completes.
The queue you specify should be a concurrent queue that you create yourself using the
dispatch function. If the queue you pass to this function is a serial queue or one of the global concurrent queues, this function behaves like the
dispatch, no retain is performed on the target queue. Because calls to this function are synchronous, it "borrows" the reference of the caller. Moreover, no
Block is performed on the block.
As an optimization, this function invokes the barrier block on the current thread when possible.