Re: Singletons with ARC
Re: Singletons with ARC
- Subject: Re: Singletons with ARC
- From: Uli Kusterer <email@hidden>
- Date: Fri, 09 Dec 2011 10:46:24 +0100
On Dec 9, 2011, at 6:18 AM, Abdul Sowayan wrote:
> + (MyClass *)sharedInstance
> {
> static MyClass *sharedInstance = nil;
>
> if(sharedInstance == nil)
> {
> @synchronized(self)
> {
> if (sharedInstance == nil)
> sharedInstance = [[self alloc] init];
> }
> }
>
> return sharedInstance;
> }
Ah, wait. Somehow I misread that code. Nevermind my question about whether this occurs in practice, but thanks go to Jean-Daniel and Andreas for their answers. It's nice to know more about this. I guess I'm still wary about the whole "an assignment may not be an atomic operation" thing on older CPUs that I did it right "by accident" :-)
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden