Awesome Open Source
Awesome Open Source
Dispatch ## Build Status
Branch Status
master Bunch Status
develop Bunch Status


Swift 3.0 Platforms License

Carthage compatible Podspec

codebeat badge codecov


Dispatch requires swift 3.0. Use version 1.0.0 for swift 2.3 or version 0.9.8 for swift 2.2.



Dispatch is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Dispatch'


Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Dispatch into your Xcode project using Carthage, specify it in your Cartfile:

github "Swiftification/Dispatch"

Run carthage update to fetch the Dispatch library and drag into your Xcode project.

And then simply

import DispatchFramework

And your good to go!


  1. Download and drop Dispatch.swift anywhere you like in your project.
  2. That's it.



Dispatch.async(dispatch_get_main_queue()) {
  //Code to be run on the main thread
Or using the helpers provided by Dispatch.Queue enum
Dispatch.async(Queue.main) {
  //Code to be run on the main thread
Or using the overloaded method to run on the main thread
Dispatch.async {
  //Code to be run on the main thread

Types of Dispatch


Dispatch.async(Queue.main) {
  //Code to be run on the main thread


let someCustomQueue = dispatch_queue_create("custom.queue.dispatch", DISPATCH_QUEUE_CONCURRENT)
Dispatch.sync(someCustomQueue) {
  //Code to be synchronously on someCustomQueue


Dispatch.after(1.0, queue: Queue.main) {
  //Code to be run on the main thread after 1 second
Or using the overloaded method to run on the main thread
Dispatch.after(1.0) {
  //Code to be run on the main thread after 1 second


let token : dispatch_once_t
Dispatch.once(&token) {
  //Code to be run only once in App lifetime

Queue Helpers

Main queue

let mainQueue = Queue.main 

Custom queue

let customConcurrentQueue = Queue.custom("custom.concurrent.queue.dispatch", Queue.Atribute.concurrent)
let customSerialQueue = Queue.custom("custom.serial.queue.dispatch", Queue.Atribute.serial)

Global queues

let priority = 0 // or you use one of the Global priorities (ex: Queue.Priority.UserInteractive)
let globalQueue =

// For comodity there are helpers for getting the Global queues

let globalUserInteractiveQueue = Queue.globalUserInteractive
let globalUserInitiatedQueue = Queue.globalUserInitiated
let globalUtilityQueue = Queue.globalUtility
let globalBackgroundQueue = Queue.globalBackground


  • [X] Carthage compatible
  • [X] Chainable methods
  • [X] Travis CI
  • [X] Unit Tests
  • [ ] More examples


  • If you find a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.



Dispatch is available under the MIT license. See the LICENSE file for more info.

Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Swift (65,929
Multithreading (2,061
Gcd (643
Gdc (22