Schedules a barrier operation on the specified channel.


void dispatch_io_barrier(dispatch_io_t channel, dispatch_block_t barrier);



The channel on which you want to schedule the barrier.


The block to execute when all previously scheduled operations on the channel have completed.


A barrier operation is a way to ensure that no new channel-related operations is executed until all previous operations have completed and the specified barrier block has been executed. The barrier operation applies to the channel’s file descriptor and not to a specific channel. In other words, if multiple channels are associated with the same file descriptor, a barrier operation scheduled on any of the channels acts as a barrier across all of the channels. All previously scheduled operations on any of those channels must complete before the barrier block is executed.

While the barrier block is running, it may safely operate on the channel’s underlying file descriptor using fsync, lseek, and similar functions, but the block must not close the file descriptor.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software