Multi-threaded Objective-C accessors: GCD vs locks
I'm debating whether or not to move to a GCD-based pattern for multi-threaded accessors. I've been using custom lock-based synchronization in accessors for years, but I've found some info ( Intro to GCD ) and there seems to be pros of a GCD-based approach. I'm hoping to start a dialog here to help myself and others weigh the decision. The pattern looks like: - (id)something { __block id localSomething; dispatch_sync(queue, ^{ localSomething = [something retain]; }); return [localSomething autorelease]; } - (void)setSomething:(id)newSomething { dispatch_async(queue, ^{ if(newSomething !=