DispatchQueue
class DispatchQueueclass DispatchQueueimport Dispatchclass DispatchObjectprotocol SendableA thread-safe type whose values can be shared across arbitrary concurrent contexts without introducing a risk of data races. Values of the type may have no shared mutable state, or they may protect that state with a lock or by forcing it to only be accessed from a specific actor.
convenience init(label: String, qos: DispatchQoS = .unspecified, attributes: DispatchQueue.Attributes = [], autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency = .inherit, target: DispatchQueue? = nil) class var main: DispatchQueue { get }class func concurrentPerform(iterations: Int, execute work: (Int) -> Void) class func getSpecific<T>(key: DispatchSpecificKey<T>) -> T? class func global(priority: DispatchQueue.GlobalQueuePriority) -> DispatchQueue class func global(qos: DispatchQoS.QoSClass = .default) -> DispatchQueue var label: String { get }var qos: DispatchQoS { get }func async(execute workItem: DispatchWorkItem) Submits a work item for asynchronous execution on a dispatch queue.
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.
func async(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.
func asyncAfter(deadline: DispatchTime, execute: DispatchWorkItem) Submits a work item to a dispatch queue for asynchronous execution after a specified time.
func asyncAfter(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.
func asyncAfter(wallDeadline: DispatchWallTime, execute: DispatchWorkItem) Submits a work item to a dispatch queue for asynchronous execution after a specified time.
func asyncAfter(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.
func getSpecific<T>(key: DispatchSpecificKey<T>) -> T? func setSpecific<T>(key: DispatchSpecificKey<T>, value: T?) func sync<T>(execute work: () throws -> T) rethrows -> T Submits a block for synchronous execution on this queue.
func sync(execute workItem: DispatchWorkItem) Submits a block for synchronous execution on this queue.
func sync(execute workItem: () -> ()) func sync<T>(flags: DispatchWorkItemFlags, execute work: () throws -> T) rethrows -> T Submits a block for synchronous execution on this queue.
struct Attributesenum AutoreleaseFrequencyenum GlobalQueuePriorityimport NIOCoreThe core abstractions that make up SwiftNIO.
@preconcurrency func asyncWithFuture<NewValue>(eventLoop: any EventLoop, _ callbackMayBlock: @escaping () throws -> NewValue) -> EventLoopFuture<NewValue> where NewValue : Sendable Schedules a work item for immediate execution and immediately returns with an EventLoopFuture providing the result. For example:
import _AsyncFileSystemfunc scheduleOnQueue<T>(work: @escaping () throws -> T) async throws -> T Schedules blocking synchronous work item on this DispatchQueue instance.
import Basicsstatic let sharedConcurrent: DispatchQueuefunc scheduleOnQueue<T>(work: @escaping () throws -> T) async throws -> T