<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Dispatch",
  "identifier" : "/documentation/Dispatch",
  "metadataVersion" : "0.1.0",
  "role" : "Framework",
  "symbol" : {
    "kind" : "Framework",
    "modules" : [
      "Dispatch"
    ],
    "preciseIdentifier" : "Dispatch"
  },
  "title" : "Dispatch"
}
-->

# Dispatch

Execute code concurrently on multicore hardware by submitting work to dispatch queues managed by the system.

## Overview

Dispatch, also known as Grand Central Dispatch (GCD), contains language features, runtime libraries, and system enhancements that provide systemic, comprehensive improvements to the support for concurrent code execution on multicore hardware in macOS, iOS, watchOS, and tvOS.

The BSD subsystem, Core Foundation, and Cocoa APIs have all been extended to use these enhancements to help both the system and your application to run faster, more efficiently, and with improved responsiveness. Consider how difficult it is for a single application to use multiple cores effectively, let alone to do it on different computers with different numbers of computing cores or in an environment with multiple applications competing for those cores. GCD, operating at the system level, can better accommodate the needs of all running applications, matching them to the available system resources in a balanced fashion.

### Dispatch Objects and ARC

When you build your app using the Objective-C compiler, all dispatch objects are Objective-C objects. As such, when automatic reference counting (ARC) is enabled, dispatch objects are retained and released automatically, just like any other Objective-C object. When ARC is not enabled, use the [`dispatch_retain`](/documentation/Dispatch/dispatch_retain) and [`dispatch_release`](/documentation/Dispatch/dispatch_release) functions (or Objective-C semantics) to retain and release your dispatch objects. You cannot use the Core Foundation retain and release functions.

If you need to use retain and release semantics in an ARC-enabled app with a later deployment target (for maintaining compatibility with existing code), you can disable Objective-C-based dispatch objects by adding `-DOS_OBJECT_USE_OBJC=0` to your compiler flags.

## Topics

### Queues and Tasks

[`class DispatchQueue`](/documentation/Dispatch/DispatchQueue)

An object that manages the execution of tasks serially or concurrently on your app’s main thread or on a background thread.

[`class DispatchWorkItem`](/documentation/Dispatch/DispatchWorkItem)

The work you want to perform, encapsulated in a way that lets you attach a completion handle or execution dependencies.

[`class DispatchGroup`](/documentation/Dispatch/DispatchGroup)

A group of tasks that you monitor as a single unit.

[`static dispatch_queue_main_tdispatch_get_main_queue();`](/documentation/Dispatch/dispatch_get_main_queue)

Returns the serial dispatch queue associated with the application’s main thread.

[`extern dispatch_queue_global_tdispatch_get_global_queue(intptr_t identifier, uintptr_t flags);`](/documentation/Dispatch/dispatch_get_global_queue)

Returns a system-defined global concurrent queue with the specified quality-of-service class.

[Dispatch Queue](/documentation/Dispatch/dispatch-queue)

An object that manages the execution of tasks serially or concurrently on your app’s main thread or on a background thread.

[Dispatch Work Item](/documentation/Dispatch/dispatch-work-item)

The work you want to perform, encapsulated in a way that lets you attach a completion handle or execution dependencies.

[Dispatch Group](/documentation/Dispatch/dispatch-group)

A group of tasks that you monitor as a single unit.

[Workloop](/documentation/Dispatch/workloop)

A dispatch object that prioritizes the execution of tasks based on their quality-of-service (QoS) level.

### Thread Scheduling

[`struct DispatchQoS`](/documentation/Dispatch/DispatchQoS)

The quality of service, or the execution priority, to apply to tasks.

[`typedef qos_class_t dispatch_qos_class_t;`](/documentation/Dispatch/dispatch_qos_class_t)

Quality-of-service classes that specify the priorities for executing tasks.

[`typedef long dispatch_queue_priority_t;`](/documentation/Dispatch/dispatch_queue_priority_t)

The execution priority for tasks in a global concurrent queue.

[`extern void dispatch_set_qos_class_floor(dispatch_object_t object, dispatch_qos_class_t qos_class, int relative_priority);`](/documentation/Dispatch/dispatch_set_qos_class_floor)

Specifies the minimum quality-of-service level for a dispatch queue, source, or workloop.

### System Event Monitoring

[`class DispatchSource`](/documentation/Dispatch/DispatchSource)

An object that coordinates the processing of specific low-level system events, such as file-system events, timers, and UNIX signals.

[Dispatch Source](/documentation/Dispatch/dispatch-source)

An object that coordinates the processing of specific low-level system events, such as file-system events, timers, and UNIX signals.

[`class DispatchIO`](/documentation/Dispatch/DispatchIO)

An object that manages operations on a file descriptor using either stream-based or random-access semantics.

[`struct DispatchData`](/documentation/Dispatch/DispatchData)

An object that manages a memory-based data buffer and exposes it as a contiguous block of memory.

[`struct DispatchDataIterator`](/documentation/Dispatch/DispatchDataIterator)

A byte-by-byte iterator over the contents of a dispatch data object.

[Dispatch I/O](/documentation/Dispatch/dispatch-i-o)

An object that manages operations on a file descriptor using either stream-based or random-access semantics.

[Dispatch Data](/documentation/Dispatch/dispatch-data)

An object that manages a memory-based data buffer and exposes it as a contiguous block of memory.

[`protocol DispatchSourceProtocol`](/documentation/Dispatch/DispatchSourceProtocol)

Defines a common set of properties and methods that are shared with all dispatch source types.

### Task Synchronization

[`class DispatchSemaphore`](/documentation/Dispatch/DispatchSemaphore)

An object that controls access to a resource across multiple execution contexts through use of a traditional counting semaphore.

[Dispatch Semaphore](/documentation/Dispatch/dispatch-semaphore)

An object that controls access to a resource across multiple execution contexts through use of a traditional counting semaphore.

[Dispatch Barrier](/documentation/Dispatch/dispatch-barrier)

A synchronization point for tasks executing in a concurrent dispatch queue.

### Time Constructs

[`struct DispatchTime`](/documentation/Dispatch/DispatchTime)

A point in time relative to the default clock, with nanosecond precision.

[`struct DispatchWallTime`](/documentation/Dispatch/DispatchWallTime)

An absolute point in time according to the wall clock, with microsecond precision.

[`enum DispatchTimeInterval`](/documentation/Dispatch/DispatchTimeInterval)

A number of seconds, millisconds, microseconds, or nanoseconds.

[`enum DispatchTimeoutResult`](/documentation/Dispatch/DispatchTimeoutResult)

A result value indicating whether a dispatch operation finished before a specified time.

[`extern dispatch_time_t dispatch_time(dispatch_time_t when, int64_t delta);`](/documentation/Dispatch/dispatch_time)

Creates a `dispatch_time_t` relative to the default clock or modifies an existing `dispatch_time_t`.

[`extern dispatch_time_t dispatch_walltime(const struct timespec *when, int64_t delta);`](/documentation/Dispatch/dispatch_walltime)

Creates a `dispatch_time_t` using an absolute time according to the wall clock.

[`typealias dispatch_time_t`](/documentation/Dispatch/dispatch_time_t)

An abstract representation of time.

[`var DISPATCH_WALLTIME_NOW: UInt`](/documentation/Dispatch/DISPATCH_WALLTIME_NOW)

The current time.

[Wall Time Constants](/documentation/Dispatch/2963138-wall-time-constants)

Constants for wall time values.

### Dispatch Objects

[`class DispatchObject`](/documentation/Dispatch/DispatchObject)

The base class for most dispatch types.

[`enum DispatchPredicate`](/documentation/Dispatch/DispatchPredicate)

Logical conditions to evaluate within a given execution context.

[`func dispatchPrecondition(condition: @autoclosure () -> DispatchPredicate)`](/documentation/Dispatch/dispatchPrecondition(condition:))

Checks a dispatch condition necessary for further execution.

[Dispatch Objects](/documentation/Dispatch/dispatch-objects)

The basic behaviors supported by all dispatch types.

### Deprecated

[Deprecated Symbols](/documentation/Dispatch/deprecated-symbols)

### Classes

[`class DispatchWorkloop`](/documentation/Dispatch/DispatchWorkloop)

### Protocols

[`@protocol OS_dispatch_queue_serial_executor <OS_dispatch_queue>`](/documentation/Dispatch/OS_dispatch_queue_serial_executor)

### Reference

[Dispatch Constants](/documentation/Dispatch/dispatch-constants)

[Dispatch Data Types](/documentation/Dispatch/dispatch-data-types)

[Dispatch Functions](/documentation/Dispatch/dispatch-functions)



---

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)