<!--
{
  "availability" : [
    "iOS: 4.3.0 -",
    "iPadOS: 4.3.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Dispatch",
  "identifier" : "/documentation/Dispatch/dispatch_barrier_sync",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Dispatch"
    ],
    "preciseIdentifier" : "c:@F@dispatch_barrier_sync"
  },
  "title" : "dispatch_barrier_sync"
}
-->

# dispatch_barrier_sync

Submits a barrier block object for execution and waits until that block completes.

```
extern void dispatch_barrier_sync(dispatch_queue_t queue, dispatch_block_t block);
```

## Parameters

`queue`

The dispatch queue on which to execute the barrier block. This parameter cannot be `NULL`.

`block`

The barrier block to execute. This parameter cannot be `NULL`.

## Discussion

This function submits a barrier block to a dispatch queue for synchronous execution. Unlike [`dispatch_barrier_async`](/documentation/Dispatch/dispatch_barrier_async), 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_queue_create`](/documentation/Dispatch/dispatch_queue_create) 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 [`sync(execute:)`](/documentation/Dispatch/DispatchQueue/sync(execute:)-3segw) function.

Unlike with [`dispatch_barrier_async`](/documentation/Dispatch/dispatch_barrier_async), 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_copy` is performed on the block.

As an optimization, this function invokes the barrier block on the current thread when possible.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)