Skip to content

Instantly share code, notes, and snippets.

@abbeyjackson
Created October 13, 2016 19:32
Show Gist options
  • Save abbeyjackson/9864327096623fce0f7427fb1422e3c9 to your computer and use it in GitHub Desktop.
Save abbeyjackson/9864327096623fce0f7427fb1422e3c9 to your computer and use it in GitHub Desktop.
Creating a concurrent queue
let concurrentQueue = DispatchQueue(label: "queuename", attributes: .concurrent)
concurrentQueue.sync {
}
Create a serial queue
let serialQueue = DispatchQueue(label: "queuename")
serialQueue.sync {
}
Get main queue asynchronously
DispatchQueue.main.async {
}
Get main queue synchronously
DispatchQueue.main.sync {
}
To get one of the background thread
DispatchQueue.global(attributes: .qosDefault).async {
}
Xcode 8 beta 5:
To get one of the background thread
DispatchQueue.global(qos: DispatchQoS.QoSClass.default).async {
}
DispatchQueue.global().async {
// qos' default value is ´DispatchQoS.QoSClass.default`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment