[libdispatch-dev] dispatch_suspend() does not affect child queues

Michael Roitzsch mroi at os.inf.tu-dresden.de
Sun Aug 5 10:06:44 PDT 2012


Hi libdispatch team,

I have a question regarding the indented behavior and use of dispatch multiple queues: If a queue A has its target set to queue B and queue B is suspended with dispatch_suspend(B), why are blocks from queue A still executed?

I was expecting dispatch_suspend(X) to silence the entire subsystem of queues directly or indirectly targeting queue X, but it does not. Instead, only the queue X I pass in is suspended, all other queues seem unaffected.

I attached an Xcode project (tested on OS X 10.8.0) to demonstrate the issue. I am using two serial queues "low" and "high" to implement the front enqueue pattern to execute emergency work: The "low" queue targets the "high" queue. Blocks are usually enqueued on "low", emergency work is enqueued on "high" so it can bypass all the work queued in "low".

This works fine when line 27 is commented out. However, as soon as I give a different subsystem of my code (imagine this being a third party library) access to the "low" queue, this subsystem can create a hidden private queue that feeds into "low". The emergency block will now experience undue delay, because suspending the "low" queue does not suspend the private queue.

I would like to understand the rationale for this behavior of libdispatch.

Michael

-------------- next part --------------
A non-text attachment was scrubbed...
Name: GCD-Test.zip
Type: application/zip
Size: 2619 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/libdispatch-dev/attachments/20120805/ddf7dbc5/attachment.zip>


More information about the libdispatch-dev mailing list