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

# dispatch_assert_queue

Generates an assertion if the current block is not running on the specified dispatch queue.

```
extern void dispatch_assert_queue(dispatch_queue_t queue);
```

## Parameters

`queue`

The dispatch queue where you expect the current block to be running. This parameter must not be `NULL`.

## Discussion

Use this function inside a block to verify that the block is running on the expected dispatch queue. For example, you might pass the main queue to the `queue` parameter to verify that the block is running on the app’s main thread. If you submitted the current block synchronously, the function recursively checks the context of the submitting block to ensure that it is also running on the expected dispatch queue. If the block is not running on the expected queue, this function asserts, logs an explanation to the system log, and terminates the app.

This function evaluates where the block is actually executing. For example, if you submit the block to a dispatch queue that targets a different queue, the block is considered to be running on the target queue.

Calling this function outside of a block running on a dispatch queue is a programmer error. If you do so, the function asserts and terminates your app.

---

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)