Because you make 2 queues, doesn't mean internally they will operate on separate cores/threads. GCD may coalesce these based on system resources. I agree with the best practice you outlined; however, the example in this email thread has 2 queues within the same subsystem. So there must be some "trick" I am not groc'ing within the snippet of code. Anyhow, I think the OP got the answer to his original question.
-Tony On Jun 18, 2010, at 12:34 PM, Bill Bumgarner wrote: > > On Jun 18, 2010, at 12:09 PM, Tony Romano wrote: > >> First, the objects are retained by dispatch_async as others have mentioned. >> Second, I'm not sure why you used 2 queues for the tasks in your code, seems >> overly complex. Async queues are serialized, which means that you can >> continue to add to the queue and the jobs will be done in order which they >> were added. The next job will not start until the previous one in the queue >> is completed. > > To be precise, it is the Blocks runtime that takes care of memory management, > triggered by dispatch_async()s copying of the block passed to it. > > As for their being two queues, that pattern is actually pretty common. A > best practice is to subdivide your application into subsystems and then have > one (or more, depending on concurrency used) queue per subsystem. The > queues both allow the application to do work across many cores simultaneously > while also providing a natural lock-less exclusion primitive per subsystem. > > The trick is to keep the object graphs being acted upon within the subsystems > relatively isolated from each other (with the points of contention being > carefully considered). > > b.bum > > -Tony _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com