DispatchQueue

class DispatchQueue : DispatchObject
  • Asynchronously executes the provided closure on a dispatch queue.

    let context = DispatchQueue.global().asyncCC(.promise) {
        try md5(input)
    }.done { md5 in
        //…
    }.cancelContext
    
    //…
    
    context.cancel()
    

    Declaration

    Swift

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

    Parameters

    cancelValue

    The value to use if the CancellableGuarantee is cancelled.

    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.

    let context = DispatchQueue.global().asyncCC(.promise) {
        try md5(input)
    }.done { md5 in
        //…
    }.cancelContext
    
    //…
    
    context.cancel()
    

    Declaration

    Swift

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

    Parameters

    cancelValue

    No-op – workaround for compiler problem, can get ‘ambiguous use of asynCC’ error otherwise

    body

    The closure that resolves this promise.

    Return Value

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