[libdispatch-dev] Clarification on default target_queue for custom serial queues

Daniel A. Steffen dsteffen at apple.com
Mon Jun 27 14:25:54 PDT 2011

On Jun 27, 2011, at 1:59 PM, Daniel Shusta wrote:

> So custom serial queues default to a different global queue, interesting. But what are the reasons for this default, and what are the downsides of non-overcommiting queues versus overcommitting ones? I mean, non-overcommitting queues still spawn new threads if it blocks.

the reason was essentially better compatibility for code that migrated from pthreads to serial queues (with a direct mapping of one pthread -> one serial queue).
E.g. on a single core machine, code keeping one serial queue permanently busy (with a single block) can prevent another serial queue from ever running, something which is not possible with two pthreads.

> Would there be a concern if I just retargeted all the queues in my apps to non-overcommiting global queues? Anecdotally, it seems to help UI responsiveness (main thread doesn’t get crowded out?), so that’s a benefit right there. 

For new code architected with GCD in mind, setting the target queue of your serial queues to non-overcommit by default seems like a very sensible idea.


More information about the libdispatch-dev mailing list