On Wed, Sep 14, 2011 at 11:00 AM, Dave Zarzycki <zarzy...@apple.com> wrote:
> Dispatch queues exist to solve both the synchronous and asynchronous 
> producer/consumer pattern. If you want the producer to wait until the 
> consumer is done, then use dispatch_sync() instead of dispatch_async():
>
>        x = create_something();
>        dispatch_sync(consumer_q, ^{
>                do_something_with(x);
>        });
>        // do_something_with() is done
>
> That's it. Easy, huh? :-)

I think the point is to wait until the _handoff_, not necessarily
until the consumer is finished _consuming_. For example, the producer
can work on producing the next object to be consumed while the
consumer is consuming the previous one.

I think using the dispatch_sync(some_q, ^{ dispatch_async(some_q,
^{}); }) technique accomplishes that.

--Kyle Sluder
_______________________________________________

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

Reply via email to