DispatchQueue

public extension DispatchQueue
  • Asynchronously executes the provided closure on a dispatch queue.

    DispatchQueue.global().async(.promise) {
        md5(input)
    }.done { md5 in
        //…
    }
    

    Note

    There is no Promise/Thenable version of this due to Swift compiler ambiguity issues.

    Declaration

    Swift

    @available(macOS 10.10, iOS 2.0, tvOS 10.0, watchOS 2.0, *)
    final func async<T>(_: PMKNamespacer, group: DispatchGroup? = nil, qos: DispatchQoS = .default, flags: DispatchWorkItemFlags = [], execute body: @escaping () -> T) -> Guarantee<T>

    Parameters

    body

    The closure that resolves this promise.

    Return Value

    A new Guarantee resolved by the result of the provided closure.

  • Asynchronously executes the provided closure on a dispatch queue.

    DispatchQueue.global().async(.promise) {
        try md5(input)
    }.done { md5 in
        //…
    }
    

    Note

    There is no Promise/Thenable version of this due to Swift compiler ambiguity issues.

    Declaration

    Swift

    @available(macOS 10.10, iOS 8.0, tvOS 9.0, watchOS 2.0, *)
    final func async<T>(_: PMKNamespacer, group: DispatchGroup? = nil, qos: DispatchQoS = .default, flags: DispatchWorkItemFlags = [], execute body: @escaping () throws -> T) -> Promise<T>

    Parameters

    body

    The closure that resolves this promise.

    Return Value

    A new Promise resolved by the result of the provided closure.