On Oct 19, 2010, at 8:15 PM, Abhi Beckert wrote: > Hi, > > According to the documentation dispatch_sync(dispatch_get_main_queue(), ^{ > ... }) will lockup if you are already on the main queue. > > I have several methods which can be called from either a background queue or > the main queue, but parts of them *must* be run on the main queue. What is a > clean workaround for this? I'd like to do something like: > > - (void)foo > { > dispatch_block_t fooBlock = ^{ > NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; > > /* do stuff */ > > [pool release]; > }; > > if (dispatch_get_current_queue() == dispatch_get_main_queue()) > dispatch_exec_block(fooBlock); > else > dispatch_sync(dispatch_get_main_queue(), fooBlock); > } > > I made up dispatch_exec_block(), it must exist, but I can't find it?
fooBlock()? Charles_______________________________________________ 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