[libdispatch-dev] Queue size

Dave Zarzycki zarzycki at apple.com
Thu Oct 7 09:20:46 PDT 2010


On Oct 7, 2010, at 11:54 AM, Thomas Clement wrote:

> On Oct 7, 2010, at 5:14 PM, Dave Zarzycki wrote:
> 
>> That would be a "latent serialization" problem that was hinted at in my response. The dirty secret of our industry is that many thread safe libraries are not actually designed to achieve any concurrency when invoked concurrently. This creates huge problems for developers like yourself that are trying to use them concurrently.
>> 
>>> It is difficult if not impossible to remove these locks. I guess the solution is to limit the number of dispatched blocks on my queues using dispatch semaphores.
>> 
>> The solution is to desynchronize the subsystem in question and switch to completion callbacks. In other words, do this kind of transform:
>> 
>> 	Result *foo(Input *x);
>> 
>> …becomes:
>> 
>> 	void foo(Input *x, dispatch_queue_t completion_queue, void (^completion_callback)(Result *));
> 
> I see.
> This also means I shouldn't use dispatch_sync() in those subsystems and always use dispatch_async() instead?

Thomas,

Yes. Where possible, dispatch_async() is preferable to dispatch_sync().

davez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/libdispatch-dev/attachments/20101007/ec24f532/attachment-0001.html>


More information about the libdispatch-dev mailing list