O'Reilly logo

Mastering Swift 4 - Fourth Edition by Jon Hoffman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating queues

We use the DispatchQueue initializer to create a new dispatch queue. The following code shows how we would create a new dispatch queue:

let concurrentQueue = DispatchQueue(label: "cqueue.hoffman.jon",                                    attributes: .concurrent) 
let serialQueue = DispatchQueue(label: "squeue.hoffman.jon") 

The first line would create a concurrent queue with the label of cqueue.hoffman.jon, while the second line would create a serial queue with the label of squeue.hoffman.jon.

The DispatchQueue initializer takes the following parameters:

  • label: This is a string label that is attached to the queue to uniquely identify it in debugging tools, such as instruments and crash reports. It is recommended that we use a reverse DNS naming convention. This ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required