I regularly see folks write code like this:
DispatchQueue.global().async {
… do stuff …
}
This relies on a Dispatch global concurrent queue. Using such queues directly is almost always a mistake. That’s because a global concurrent queue might [1] overcommit — that is, start more threads than there are CPU cores — resulting in needless inefficiency. In the worse case this can trigger a phenomenon known as thread explosion, which is about as much fun as it sounds.
My general advice is that you avoid concurrent queues in almost all circumstances. For more background on this, see:
-
WWDC 2015 Session 718 Building Responsive and Efficient Apps with GCD
-
WWDC 2017 Session 706 Modernizing Grand Central Dispatch Usage
If you have any follow comments or questions, please start a new thread, tagging it with Dispatch, and I’ll respond there.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] Whether it will overcommit is a more complex question (-:
(r. 98175345)