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.
- ClDispatchQueue@typedef dispatch_queue_t
- ClDispatchSerialQueueiOS 12.0+@typedef dispatch_queue_serial_t
- ClDispatchConcurrentQueueiOS 12.0+@typedef dispatch_queue_concurrent_t
- ClDispatchWorkloopiOS 12.0+@typedef dispatch_workloop_t
- ClOS_dispatch_queue_global@typedef dispatch_queue_global_t
- ClOS_dispatch_queue_main@typedef dispatch_queue_main_t
- Cl_DispatchSerialExecutorQueueiOS 17.0+@typedef dispatch_queue_serial_executor_t
- ClDispatchSpecificKeyA 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.
- ClDispatchWorkItemiOS 8.0+An encapsulation of work that you can submit to a queue, cancel, or wait on.
- StDispatchWorkItemFlagsOptions 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.
- ClDispatchGroup@typedef dispatch_group_t
- ClDispatchSemaphore@typedef dispatch_semaphore_t
Dispatch Sources 14
Objects and protocols that monitor low-level system events and dispatch handlers in response.
- ClDispatchSource@typedef dispatch_source_t
- PrDispatchSourceProtocol@typedef dispatch_source_t
- PrDispatchSourceTimerA dispatch source that submits a handler at a scheduled time and optional repeating interval.
- PrDispatchSourceReadA dispatch source that signals when data is available to read from a file descriptor.
- PrDispatchSourceWriteA dispatch source that signals when a file descriptor is ready to accept written data.
- PrDispatchSourceSignalA dispatch source that monitors the delivery of a specified Unix signal.
- PrDispatchSourceProcessA dispatch source that monitors another process for state changes such as exit or signal.
- PrDispatchSourceMemoryPressureA dispatch source that monitors the system's memory pressure conditions.
- PrDispatchSourceFileSystemObjectA dispatch source that monitors a file descriptor for file-system events such as writes or deletes.
- PrDispatchSourceMachSendA dispatch source that monitors a Mach port for the availability of send rights.
- PrDispatchSourceMachReceiveA dispatch source that monitors a Mach port for pending messages to receive.
- PrDispatchSourceUserDataAddA dispatch source that coalesces application-defined events by summing the data you supply.
- PrDispatchSourceUserDataOrA dispatch source that coalesces application-defined events by bitwise-ORing the data you supply.
- PrDispatchSourceUserDataReplaceA 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.
- StDispatchTimeA point in time relative to the system clock, used to schedule dispatch operations.
- StDispatchWallTimeA point in time relative to the wall clock, used to schedule dispatch operations.
- EnDispatchTimeIntervalRepresents a time interval that can be used as an offset from a `DispatchTime`
- StDispatchQoSqos_class_t
Asynchronous I/O and Data 4
Types for performing efficient asynchronous I/O and managing contiguous memory buffers.
- ClDispatchIO@typedef dispatch_io_t
- StDispatchDataA type that manages a buffer of contiguous bytes for efficient memory and I/O operations.
- StDispatchDataIteratorAn 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.
- ClDispatchObjectThe base class for dispatch objects that supports activation, suspension, and target-queue assignment.
- EnDispatchPredicateiOS 10.0+dispatch_assert
- En__dispatch_autorelease_frequency_t@typedef dispatch_autorelease_frequency_t
Enumerations 1
- EnDispatchTimeoutResult
Type Aliases 16
- Tydispatch_time_t@typedef dispatch_time_t
- Tydispatch_object_t
- Tydispatch_queue_t@typedef dispatch_queue_t
- Tydispatch_queue_global_t@typedef dispatch_queue_global_t
- Tydispatch_queue_serial_executor_t@typedef dispatch_queue_serial_executor_t
- Tydispatch_queue_serial_t@typedef dispatch_queue_serial_t
- Tydispatch_queue_main_t@typedef dispatch_queue_main_t
- Tydispatch_queue_concurrent_t@typedef dispatch_queue_concurrent_t
- Tydispatch_queue_attr_t@typedef dispatch_queue_attr_t
- Tydispatch_source_t@typedef dispatch_source_t
- Tydispatch_source_mach_recv_flags_t@typedef dispatch_source_mach_recv_flags_t
- Tydispatch_group_t@typedef dispatch_group_t
- Tydispatch_semaphore_t@typedef dispatch_semaphore_t
- Tydispatch_data_t@typedef dispatch_data_t
- Tydispatch_io_t@typedef dispatch_io_t
- Tydispatch_workloop_t@typedef dispatch_workloop_t