> On Apr 25, 2014, at 10:35 AM, Seth Willits <sli...@araelium.com> wrote:
> 
>> On Apr 25, 2014, at 8:08 AM, Jens Alfke <j...@mooseyard.com> wrote:
>> 
>> I’m ending up at the opposite of the received wisdom, namely:
>> * dispatch_sync is a lot cheaper than dispatch_async
>> * only use dispatch_async if you really need to, or for an expensive 
>> operation, because it will slow down all your dispatch_sync calls
> 
> Saying "dispatch_async will slow down *all* dispatch_sync calls" throws up 
> red flags for me.
> 
> In my mind there's still a possibility that You're Doing It Wrong.

FWIW, I’ve been of the opinion for a while that including dispatch_sync in the 
API was a mistake.  Too often it becomes a crutch used without understanding, 
resulting in stop-start behavior across threads or cores. The correct solution 
is usually to rewrite the code in continuation-passing style, even if that 
means a cascade of blocks. Microsoft realized this when designing WinRT and 
_removed all the synchronous APIs_. They also added the async/await keywords to 
C# to avoid the seventeen-levels-of-indentation problem that plagues ObjC code.

Some people at Apple agree that use of dispatch_sync is a code smell, but that 
if they didn't include it a hundred different re-implementations would arise, 
all differently broken.

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to