One Logo Pool Ball
Dispatch · IOS API REFERENCE

DispatchQueue

class · SDK 27.1

class DispatchQueue

Members (35)

method · iOS 12.0+

asyncAndWait

TypeScript
asyncAndWaitExecute(block: (() => void)): void
Swift declaration
func asyncAndWait(execute block: () -> Void)
method · iOS 4.0+

sync

TypeScript
syncExecute(block: (() => void)): void
Swift declaration
func sync(execute block: () -> Void)
method

asyncAfter

TypeScript
asyncAfterWallDeadlineQosFlagsExecute(wallDeadline: DispatchWallTime, qos: DispatchQoS, flags: DispatchWorkItemFlags, work: (() => void)): void
Swift declaration
@preconcurrency func asyncAfter(wallDeadline: DispatchWallTime, qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], execute work: @escaping @Sendable () -> Void)

Submits a work item to a dispatch queue for asynchronous execution after a specified time. This method enforces the work item to be sendable. - parameter: deadline the time after which the work item should be executed, given as a `DispatchWallTime`. - parameter qos: the QoS at which the work item should be executed. Defaults to `DispatchQoS.unspecified`. - parameter flags: flags that control the execution environment of the work item. - parameter execute: The work item to be invoked on the queue. - SeeAlso: `async(execute:)` - SeeAlso: `asyncAfter(wallDeadline:execute:)` - SeeAlso: `DispatchQoS` - SeeAlso: `DispatchWorkItemFlags` - SeeAlso: `DispatchWallTime`

method · iOS 8.0+

asyncAfter

TypeScript
asyncAfterWallDeadlineExecute(wallDeadline: DispatchWallTime, execute: DispatchWorkItem): void
Swift declaration
func asyncAfter(wallDeadline: DispatchWallTime, execute: DispatchWorkItem)

Submits a work item to a dispatch queue for asynchronous execution after a specified time. - parameter: deadline the time after which the work item should be executed, given as a `DispatchWallTime`. - parameter execute: The work item to be invoked on the queue. - SeeAlso: `asyncAfter(wallDeadline:qos:flags:execute:)` - SeeAlso: `DispatchTime`

method

asyncAfter

TypeScript
asyncAfterDeadlineQosFlagsExecute(deadline: DispatchTime, qos: DispatchQoS, flags: DispatchWorkItemFlags, work: (() => void)): void
Swift declaration
@preconcurrency func asyncAfter(deadline: DispatchTime, qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], execute work: @escaping @Sendable () -> Void)

Submits a work item to a dispatch queue for asynchronous execution after a specified time. This method enforces the work item to be sendable. - parameter: deadline the time after which the work item should be executed, given as a `DispatchTime`. - parameter qos: the QoS at which the work item should be executed. Defaults to `DispatchQoS.unspecified`. - parameter flags: flags that control the execution environment of the work item. - parameter execute: The work item to be invoked on the queue. - SeeAlso: `async(execute:)` - SeeAlso: `asyncAfter(deadline:execute:)` - SeeAlso: `DispatchQoS` - SeeAlso: `DispatchWorkItemFlags` - SeeAlso: `DispatchTime`

method · iOS 8.0+

asyncAfter

TypeScript
asyncAfterDeadlineExecute(deadline: DispatchTime, execute: DispatchWorkItem): void
Swift declaration
func asyncAfter(deadline: DispatchTime, execute: DispatchWorkItem)

Submits a work item to a dispatch queue for asynchronous execution after a specified time. - parameter: deadline the time after which the work item should be executed, given as a `DispatchTime`. - parameter execute: The work item to be invoked on the queue. - SeeAlso: `asyncAfter(deadline:qos:flags:execute:)` - SeeAlso: `DispatchTime`

method · iOS 17.0+

asyncUnsafe

TypeScript
asyncUnsafe(group: (DispatchGroup) | null, qos: DispatchQoS, flags: DispatchWorkItemFlags, work: (() => void)): void
Swift declaration
func asyncUnsafe(group: DispatchGroup? = nil, qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], execute work: @escaping () -> Void)

Submits a work item to a dispatch queue and optionally associates it with a dispatch group. The dispatch group may be used to wait for the completion of the work items it references. This function does not enforce sendability requirement on work item. If non-sendable objects are captured by the closure to this method, clients are responsible for manually verifying their correctness. - parameter group: the dispatch group to associate with the submitted work item. If this is `nil`, the work item is not associated with a group. - parameter qos: the QoS at which the work item should be executed. Defaults to `DispatchQoS.unspecified`. - parameter flags: flags that control the execution environment of the work item. - parameter execute: The work item to be invoked on the queue. - SeeAlso: `sync(execute:)` - SeeAlso: `DispatchQoS` - SeeAlso: `DispatchWorkItemFlags`

method

getSpecific

TypeScript
getSpecificKey(key: DispatchSpecificKey<number>): (number) | null
Swift declaration
@preconcurrency func getSpecific<T>(key: DispatchSpecificKey<T>) -> T? where T : Sendable
static

getSpecific

TypeScript
static getSpecificKey25069(key: DispatchSpecificKey<number>): (number) | null
Swift declaration
@preconcurrency class func getSpecific<T>(key: DispatchSpecificKey<T>) -> T? where T : Sendable
method

setSpecific

TypeScript
setSpecific(key: DispatchSpecificKey<number>, value?: (number) | null): void
Swift declaration
@preconcurrency func setSpecific<T>(key: DispatchSpecificKey<T>, value: T?) where T : Sendable
method · iOS 12.0+

asyncAndWait

TypeScript
asyncAndWaitFlagsExecute(flags: DispatchWorkItemFlags, work: (() => unknown)): unknown
Swift declaration
func asyncAndWait<T>(flags: DispatchWorkItemFlags, execute work: () throws -> T) rethrows -> T

Submits a work item for synchronous execution on a dispatch queue. Submits a work item to a dispatch queue like `asyncAndWait(execute:)`, and returns the value, of type `T`, returned by that work item. - parameter execute: The work item to be invoked on the queue. - returns the value returned by the work item. - SeeAlso: `asyncAndWait(execute:)`

method · iOS 12.0+

asyncAndWait

TypeScript
asyncAndWaitExecute14709(work: (() => unknown)): unknown
Swift declaration
func asyncAndWait<T>(execute work: () throws -> T) rethrows -> T

Submits a work item for synchronous execution on a dispatch queue. Submits a work item to a dispatch queue like `asyncAndWait(execute:)`, and returns the value, of type `T`, returned by that work item. - parameter execute: The work item to be invoked on the queue. - returns the value returned by the work item. - SeeAlso: `asyncAndWait(execute:)`

method · iOS 12.0+

asyncAndWait

TypeScript
asyncAndWaitExecute62953(workItem: DispatchWorkItem): void
Swift declaration
func asyncAndWait(execute workItem: DispatchWorkItem)

Submits a work item for synchronous execution on a dispatch queue. Submits a work item to a dispatch queue like `async(execute:)`, however `asyncAndWait(execute:)` will not return until the work item has finished. `asyncAndWait(excute:)` is subject to deadlock under the same conditions as `sync(execute:)`. `asyncAndWait(execute:)` differs from `sync(execute:)` in the following ways: * Work items submitted to a queue with `asyncAndWait` observe all queue attributes of that queue when invoked (including autorelease frequency or DispatchQoS class). * Work items submitted to a queue with `asyncAndWait` are not guaranteed to run on the calling thread. If the queue the work is submitted to already has a thread servicing it, the servicing thread will execute the work item submitted via `asyncAndWait`. If the queue the work is submitted to does not have any threads servicing it, the calling thread will execute the work item. As an exception, if the queue the work is submitted to doesn't target a global concurrent queue (for example because it targets the main queue or a custom priority workloop), then the work item will never be invoked by the thread calling `asyncAndWait(execute:)`. - parameter execute: The work item to be invoked on the queue. - SeeAlso: `async(execute:)` - SeeAlso: `sync(execute:)`

method · iOS 17.0+

asyncAfterUnsafe

TypeScript
asyncAfterUnsafeWallDeadlineQosFlagsExecute(wallDeadline: DispatchWallTime, qos: DispatchQoS, flags: DispatchWorkItemFlags, work: (() => void)): void
Swift declaration
func asyncAfterUnsafe(wallDeadline: DispatchWallTime, qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], execute work: @escaping () -> Void)

Submits a work item to a dispatch queue for asynchronous execution after a specified time. This function does not enforce sendability requirement on work item. If non-sendable objects are captured by the closure to this method, clients are responsible for manually verifying their correctness. - parameter: deadline the time after which the work item should be executed, given as a `DispatchWallTime`. - parameter qos: the QoS at which the work item should be executed. Defaults to `DispatchQoS.unspecified`. - parameter flags: flags that control the execution environment of the work item. - parameter execute: The work item to be invoked on the queue. - SeeAlso: `async(execute:)` - SeeAlso: `asyncAfter(wallDeadline:execute:)` - SeeAlso: `DispatchQoS` - SeeAlso: `DispatchWorkItemFlags` - SeeAlso: `DispatchWallTime`

method · iOS 17.0+

asyncAfterUnsafe

TypeScript
asyncAfterUnsafeDeadlineQosFlagsExecute(deadline: DispatchTime, qos: DispatchQoS, flags: DispatchWorkItemFlags, work: (() => void)): void
Swift declaration
func asyncAfterUnsafe(deadline: DispatchTime, qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], execute work: @escaping () -> Void)

Submits a work item to a dispatch queue for asynchronous execution after a specified time. This function does not enforce sendability requirement on work item. If non-sendable objects are captured by the closure to this method, clients are responsible for manually verifying their correctness. - parameter: deadline the time after which the work item should be executed, given as a `DispatchTime`. - parameter qos: the QoS at which the work item should be executed. Defaults to `DispatchQoS.unspecified`. - parameter flags: flags that control the execution environment of the work item. - parameter execute: The work item to be invoked on the queue. - SeeAlso: `async(execute:)` - SeeAlso: `asyncAfter(deadline:execute:)` - SeeAlso: `DispatchQoS` - SeeAlso: `DispatchWorkItemFlags` - SeeAlso: `DispatchTime`

get · iOS 13.0+

minimumTolerance

TypeScript
get minimumTolerance(): DispatchQueue_SchedulerTimeType_Stride
Swift declaration
var minimumTolerance: DispatchQueue.SchedulerTimeType.Stride { get }

The minimum tolerance allowed by the scheduler.

static

concurrentPerform

TypeScript
static concurrentPerform(iterations: number, work: ((arg0: number) => void)): void
Swift declaration
@preconcurrency class func concurrentPerform(iterations: Int, execute work: @Sendable (Int) -> Void)
method · iOS 18.4+

asUnownedTaskExecutor

TypeScript
asUnownedTaskExecutor(): SDKHandle
Swift declaration
func asUnownedTaskExecutor() -> UnownedTaskExecutor
get · iOS 13.0+

now

TypeScript
get now(): DispatchQueue_SchedulerTimeType
Swift declaration
var now: DispatchQueue.SchedulerTimeType { get }

This scheduler’s definition of the current moment in time.

get · iOS 8.0+

qos

TypeScript
get qos(): DispatchQoS
Swift declaration
var qos: DispatchQoS { get }
get

main

TypeScript
static get main(): DispatchQueue
Swift declaration
class var main: DispatchQueue { get }
method

sync

TypeScript
syncFlagsExecute(flags: DispatchWorkItemFlags, work: (() => unknown)): unknown
Swift declaration
func sync<T>(flags: DispatchWorkItemFlags, execute work: () throws -> T) rethrows -> T

Submits a block for synchronous execution on this queue. Submits a work item to a dispatch queue like `sync(execute:)`, and returns the value, of type `T`, returned by that work item. - parameter flags: flags that control the execution environment of the - parameter execute: The work item to be invoked on the queue. - returns the value returned by the work item. - SeeAlso: `sync(execute:)` - SeeAlso: `DispatchWorkItemFlags`

method

sync

TypeScript
syncExecute85623(work: (() => unknown)): unknown
Swift declaration
func sync<T>(execute work: () throws -> T) rethrows -> T

Submits a block for synchronous execution on this queue. Submits a work item to a dispatch queue like `sync(execute:)`, and returns the value, of type `T`, returned by that work item. - parameter execute: The work item to be invoked on the queue. - returns the value returned by the work item. - SeeAlso: `sync(execute:)`

method · iOS 8.0+

sync

TypeScript
syncExecute33183(workItem: DispatchWorkItem): void
Swift declaration
func sync(execute workItem: DispatchWorkItem)

Submits a block for synchronous execution on this queue. Submits a work item to a dispatch queue like `async(execute:)`, however `sync(execute:)` will not return until the work item has finished. Work items submitted to a queue with `sync(execute:)` do not observe certain queue attributes of that queue when invoked (such as autorelease frequency and QoS class). Calls to `sync(execute:)` targeting the current queue will result in deadlock. Use of `sync(execute:)` is also subject to the same multi-party deadlock problems that may result from the use of a mutex. Use of `async(execute:)` is preferred. As an optimization, `sync(execute:)` invokes the work item on the thread which submitted it, except when the queue is the main queue or a queue targetting it. - parameter execute: The work item to be invoked on the queue. - SeeAlso: `async(execute:)` - SeeAlso: `asyncAndWait(execute:)`

method

async

TypeScript
asyncGroupQosFlagsExecute(group: (DispatchGroup) | null, qos: DispatchQoS, flags: DispatchWorkItemFlags, work: (() => void)): void
Swift declaration
@preconcurrency func async(group: DispatchGroup? = nil, qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], execute work: @escaping @Sendable () -> Void)

Submits a work item to a dispatch queue and optionally associates it with a dispatch group. The dispatch group may be used to wait for the completion of the work items it references. This method enforces the work item to be sendable. - parameter group: the dispatch group to associate with the submitted work item. If this is `nil`, the work item is not associated with a group. - parameter flags: flags that control the execution environment of the - parameter qos: the QoS at which the work item should be executed. Defaults to `DispatchQoS.unspecified`. - parameter flags: flags that control the execution environment of the work item. - parameter execute: The work item to be invoked on the queue. - SeeAlso: `sync(execute:)` - SeeAlso: `DispatchQoS` - SeeAlso: `DispatchWorkItemFlags`

method · iOS 8.0+

async

TypeScript
asyncGroupExecute(group: DispatchGroup, workItem: DispatchWorkItem): void
Swift declaration
func async(group: DispatchGroup, execute workItem: DispatchWorkItem)

Submits a work item to a dispatch queue and associates it with the given dispatch group. The dispatch group may be used to wait for the completion of the work items it references. - parameter group: the dispatch group to associate with the submitted block. - parameter execute: The work item to be invoked on the queue. - SeeAlso: `sync(execute:)`

method · iOS 8.0+

async

TypeScript
asyncExecute(workItem: DispatchWorkItem): void
Swift declaration
func async(execute workItem: DispatchWorkItem)

Submits a work item for asynchronous execution on a dispatch queue. `async(execute:)` is the fundamental mechanism for submitting work items to a dispatch queue. Calls to `async(execute:)` always return immediately after the work item has been submitted, and never wait for the work item to be invoked. The target queue determines whether the work item will be invoked serially or concurrently with respect to other work items submitted to that same queue. Serial queues are processed concurrently with respect to each other. - parameter execute: The work item to be invoked on the queue. - SeeAlso: `sync(execute:)` - SeeAlso: `asyncAndWait(execute:)`

init

init

TypeScript
static init(label: string, qos?: DispatchQoS, attributes?: DispatchQueue_Attributes, autoreleaseFrequency?: DispatchQueue_AutoreleaseFrequency, target?: (DispatchQueue) | null): DispatchQueue
Swift declaration
convenience init(label: String, qos: DispatchQoS = .unspecified, attributes: DispatchQueue.Attributes = [], autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency = .inherit, target: DispatchQueue? = nil)
get

label

TypeScript
get label(): string
Swift declaration
var label: String { get }
static · iOS 8.0+

global

TypeScript
static globalQos(qos?: DispatchQoS_QoSClass): DispatchQueue
Swift declaration
class func global(qos: DispatchQoS.QoSClass = .default) -> DispatchQueue
static · Deprecated in iOS 8.0

global

TypeScript
static globalPriority(priority: DispatchQueue_GlobalQueuePriority): DispatchQueue
Swift declaration
class func global(priority: DispatchQueue.GlobalQueuePriority) -> DispatchQueue
method · iOS 18.4+

enqueue

TypeScript
enqueue(job: SDKHandle): void
Swift declaration
func enqueue(_ job: UnownedJob)
method · iOS 13.0+

schedule

TypeScript
scheduleAfterIntervalToleranceOptions(date: DispatchQueue_SchedulerTimeType, interval: DispatchQueue_SchedulerTimeType_Stride, tolerance: DispatchQueue_SchedulerTimeType_Stride, options: (DispatchQueue_SchedulerOptions) | null, action: (() => void)): SDKHandle
Swift declaration
func schedule(after date: DispatchQueue.SchedulerTimeType, interval: DispatchQueue.SchedulerTimeType.Stride, tolerance: DispatchQueue.SchedulerTimeType.Stride, options: DispatchQueue.SchedulerOptions?, _ action: @escaping () -> Void) -> any Cancellable

Performs the action at some time after the specified date, at the specified frequency, optionally taking into account tolerance if possible.

method · iOS 13.0+

schedule

TypeScript
scheduleAfterToleranceOptions(date: DispatchQueue_SchedulerTimeType, tolerance: DispatchQueue_SchedulerTimeType_Stride, options: (DispatchQueue_SchedulerOptions) | null, action: (() => void)): void
Swift declaration
func schedule(after date: DispatchQueue.SchedulerTimeType, tolerance: DispatchQueue.SchedulerTimeType.Stride, options: DispatchQueue.SchedulerOptions?, _ action: @escaping () -> Void)

Performs the action at some time after the specified date.

method · iOS 13.0+

schedule

TypeScript
scheduleOptions(options: (DispatchQueue_SchedulerOptions) | null, action: (() => void)): void
Swift declaration
func schedule(options: DispatchQueue.SchedulerOptions?, _ action: @escaping () -> Void)

Performs the action at the next possible opportunity.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

DispatchQueue.init()

inherited init: cannot prove legal (class declares 1 custom initializer)

All Dispatch types →