TechnologiesFoundation, System & Concurrency

Dispatch

iOSmacOStvOSwatchOSvisionOS

Dispatch provides Grand Central Dispatch concurrency primitives for scheduling and managing the execution of work across your app. You submit work to queues such as DispatchQueue, DispatchSerialQueue, and DispatchConcurrentQueue, encapsulate units of work as DispatchWorkItem values, and coordinate completion with DispatchGroup and DispatchSemaphore. You use DispatchSource and its protocols, including DispatchSourceTimer, DispatchSourceRead, DispatchSourceSignal, DispatchSourceProcess, and DispatchSourceMemoryPressure, to respond to low-level system events, and you express timing and priority with types like DispatchTime, DispatchTimeInterval, and DispatchQoS. DispatchIO and DispatchData support efficient asynchronous I/O and memory management on iOS, macOS, tvOS, watchOS, and visionOS.

Queues 8

The dispatch queues that schedule and execute your app's blocks of work serially or concurrently.

  • Cl
    DispatchQueue
    @typedef dispatch_queue_t
  • Cl
    DispatchSerialQueueiOS 12.0+
    @typedef dispatch_queue_serial_t
  • Cl
    DispatchConcurrentQueueiOS 12.0+
    @typedef dispatch_queue_concurrent_t
  • Cl
    DispatchWorkloopiOS 12.0+
    @typedef dispatch_workloop_t
  • Cl
    OS_dispatch_queue_global
    @typedef dispatch_queue_global_t
  • Cl
    OS_dispatch_queue_main
    @typedef dispatch_queue_main_t
  • Cl
    _DispatchSerialExecutorQueueiOS 17.0+
    @typedef dispatch_queue_serial_executor_t
  • Cl
    DispatchSpecificKey
    A key for storing and retrieving custom context data associated with a dispatch queue.

Units of Work 3

Types that encapsulate a block of work and the flags that control how it executes.

  • Cl
    DispatchWorkItemiOS 8.0+
    An encapsulation of work that you can submit to a queue, cancel, or wait on.
  • St
    DispatchWorkItemFlags
    Options that configure the execution behavior of a dispatch work item.
  • St
    __dispatch_block_flags_t
    @typedef dispatch_block_flags_t

Coordinating Work 2

Synchronization primitives for grouping, waiting on, and limiting concurrent work.

  • Cl
    DispatchGroup
    @typedef dispatch_group_t
  • Cl
    DispatchSemaphore
    @typedef dispatch_semaphore_t

Dispatch Sources 14

Objects and protocols that monitor low-level system events and dispatch handlers in response.

  • Cl
    DispatchSource
    @typedef dispatch_source_t
  • Pr
    DispatchSourceProtocol
    @typedef dispatch_source_t
  • Pr
    DispatchSourceTimer
    A dispatch source that submits a handler at a scheduled time and optional repeating interval.
  • Pr
    DispatchSourceRead
    A dispatch source that signals when data is available to read from a file descriptor.
  • Pr
    DispatchSourceWrite
    A dispatch source that signals when a file descriptor is ready to accept written data.
  • Pr
    DispatchSourceSignal
    A dispatch source that monitors the delivery of a specified Unix signal.
  • Pr
    DispatchSourceProcess
    A dispatch source that monitors another process for state changes such as exit or signal.
  • Pr
    DispatchSourceMemoryPressure
    A dispatch source that monitors the system's memory pressure conditions.
  • Pr
    DispatchSourceFileSystemObject
    A dispatch source that monitors a file descriptor for file-system events such as writes or deletes.
  • Pr
    DispatchSourceMachSend
    A dispatch source that monitors a Mach port for the availability of send rights.
  • Pr
    DispatchSourceMachReceive
    A dispatch source that monitors a Mach port for pending messages to receive.
  • Pr
    DispatchSourceUserDataAdd
    A dispatch source that coalesces application-defined events by summing the data you supply.
  • Pr
    DispatchSourceUserDataOr
    A dispatch source that coalesces application-defined events by bitwise-ORing the data you supply.
  • Pr
    DispatchSourceUserDataReplace
    A dispatch source that coalesces application-defined events by replacing the data you supply.

Time and Quality of Service 4

Types that express deadlines, intervals, wall-clock times, and execution priority.

  • St
    DispatchTime
    A point in time relative to the system clock, used to schedule dispatch operations.
  • St
    DispatchWallTime
    A point in time relative to the wall clock, used to schedule dispatch operations.
  • En
    DispatchTimeInterval
    Represents a time interval that can be used as an offset from a `DispatchTime`
  • St
    DispatchQoS
    qos_class_t

Asynchronous I/O and Data 4

Types for performing efficient asynchronous I/O and managing contiguous memory buffers.

  • Cl
    DispatchIO
    @typedef dispatch_io_t
  • St
    DispatchData
    A type that manages a buffer of contiguous bytes for efficient memory and I/O operations.
  • St
    DispatchDataIterator
    An iterator that traverses the bytes of a DispatchData buffer.
  • Cl
    __DispatchData
    @typedef dispatch_data_t

Runtime Behavior 3

Foundational object support and runtime checks that govern dispatch behavior.

  • Cl
    DispatchObject
    The base class for dispatch objects that supports activation, suspension, and target-queue assignment.
  • En
    DispatchPredicateiOS 10.0+
    dispatch_assert
  • En
    __dispatch_autorelease_frequency_t
    @typedef dispatch_autorelease_frequency_t

Enumerations 1

  • En
    DispatchTimeoutResult

Type Aliases 16

  • Ty
    dispatch_time_t
    @typedef dispatch_time_t
  • Ty
    dispatch_object_t
  • Ty
    dispatch_queue_t
    @typedef dispatch_queue_t
  • Ty
    dispatch_queue_global_t
    @typedef dispatch_queue_global_t
  • Ty
    dispatch_queue_serial_executor_t
    @typedef dispatch_queue_serial_executor_t
  • Ty
    dispatch_queue_serial_t
    @typedef dispatch_queue_serial_t
  • Ty
    dispatch_queue_main_t
    @typedef dispatch_queue_main_t
  • Ty
    dispatch_queue_concurrent_t
    @typedef dispatch_queue_concurrent_t
  • Ty
    dispatch_queue_attr_t
    @typedef dispatch_queue_attr_t
  • Ty
    dispatch_source_t
    @typedef dispatch_source_t
  • Ty
    dispatch_source_mach_recv_flags_t
    @typedef dispatch_source_mach_recv_flags_t
  • Ty
    dispatch_group_t
    @typedef dispatch_group_t
  • Ty
    dispatch_semaphore_t
    @typedef dispatch_semaphore_t
  • Ty
    dispatch_data_t
    @typedef dispatch_data_t
  • Ty
    dispatch_io_t
    @typedef dispatch_io_t
  • Ty
    dispatch_workloop_t
    @typedef dispatch_workloop_t
← Foundation, System & Concurrency