public protocol Dispatcher

A PromiseKit abstraction of a DispatchQueue that allows for a more flexible variety of implementations. (For technical reasons, DispatchQueue itself cannot be subclassed.)

Dispatchers define a dispatch method that executes a supplied closure. Execution may be synchronous or asynchronous, serial or concurrent, and can occur on any thread.

All DispatchQueues are also valid Dispatchers.

  • dispatch(_:) Default implementation


    Default Implementation

    Executes the provided closure on a Dispatcher, yielding a Promise that represents the value ultimately returned by the closure.

    dispatcher.dispatch {
       try md5(input)
    }.done { md5 in



    func dispatch(_ body: @escaping () -> Void)