On Apr 14, 2011, at 10:02 AM, WT wrote:

> I looked at dispatch_once() at one point, but I'm still confused by how it 
> works.

dispatch_once uses a predicate (just a flag) to determine if it should run the 
block or not. If that flag is false, then it sets the flag to true and executes 
the block. If the flag is true, it does nothing. What makes dispatch_once 
useful over a simple if statement is that it ensures that if you execute 
dispatch_once concurrently from multiple threads that flag gets updated exactly 
once, and the block gets called exactly once.
--
David Duncan

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to