Docs say: "For serial tasks, set the target of your serial queue to one of the global concurrent queues"
but how exactly?
DispatchQueue(label: "", target: .global(qos: .background))
// or
DispatchQueue(label: "", qos: .background, target: .global(qos: .background))
or is it the same?
context: We use quite a few serial queues in our app. In general each service (e.g. analytics, downloading, etc) has it's own serial queue to sync. access to it's resources.
The docs are a little misleading here. Specifically this comment:
For serial tasks, set the target of your serial queue to one of the global concurrent queues.
is not very helpful. If you don’t set a target queue on a serial queue, it’ll default to using one of the global concurrent queues.
However, the central thrust of that section is valid: You should use target queues to avoid creating too many threads in your app. For specific advice on how to do that, directly from one of the engineers who works on Dispatch, watch WWDC 2017 Session 706 Modernizing Grand Central Dispatch Usage.
Finally, be wary of the .background
QoS. There are situations where .background
QoS work stops completely. Last time a checked, this included low power mode on iOS.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"