Async.customQueue(queue) {} to Async.custom(queue: queue) {}group.customQueue(customQueue) {} to group.custom(queue: customQueue) {}
Description property for DispatchQueue.GlobalAttributes
public extension DispatchQueue.GlobalAttributes {
var description: String { get }
}
Internal changes
DispatchWorkItem
GCD now uses DispatchWorkItem item instead of dispatch_block_t. Functionality for notify(), wait() and cancel() are now all functions on DispatchWorkItem.
QOS
Quality of Service classes are a bit scattered now, but creating a queue looks like this:
// 2.2
let userInteractiveQueue: dispatch_queue_t = dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0)
// 3.0
let userInteractiveQueue: DispatchQueue = DispatchQueue.global(attributes: .qosUserInteractive)
Dispatch Apply – ⚠️not working ⚠️
For doing concurrent for loops, we used to be able to use dispatch_apply(iterations, queue) {} but the only API for doing it is DispatchQueue.concurrentPerform(iterations: Int) {} which is a class functions on DispatchQueue and doesn't take a queue parameter. This means we've currently lost the functionality.
Public API changes
Custom queues
Async.customQueue(queue) {}
toAsync.custom(queue: queue) {}
group.customQueue(customQueue) {}
togroup.custom(queue: customQueue) {}
Description property for
DispatchQueue.GlobalAttributes
Internal changes
DispatchWorkItem
GCD now uses
DispatchWorkItem
item instead ofdispatch_block_t
. Functionality fornotify()
,wait()
andcancel()
are now all functions onDispatchWorkItem
.QOS
Quality of Service classes are a bit scattered now, but creating a queue looks like this:
Dispatch Apply – ⚠️not working ⚠️
For doing concurrent for loops, we used to be able to use
dispatch_apply(iterations, queue) {}
but the only API for doing it isDispatchQueue.concurrentPerform(iterations: Int) {}
which is a class functions onDispatchQueue
and doesn't take a queue parameter. This means we've currently lost the functionality.