This code is my opinionated interpretation of an idea expressed by eskimo on this swift forum thread, to which I briefly partecipated. I'll try to summarize his viewpoint in this premise, as well as some of the suggestions from this gist.
- You should virtually never create a queue with
DispatchQueue.global()
nor with theconcurrent
flag. - You should create a limited number (a small Forest) of SERIAL queues (the Trees), one for each subsystem in your program.
- Apart from those base queues (the Trees), you should never create any more queues without specifying the target queue.
- You can, instead, create as many queues (the Branches) as you want, as long as they are targeting those base queues (the Trees).
- You should dispatch large chunks of code, in order to reduce the overhead of the dispatch operations.
- Therefore, you should mov