Re: Singletons with ARC
Re: Singletons with ARC
- Subject: Re: Singletons with ARC
- From: Uli Kusterer <email@hidden>
- Date: Fri, 09 Dec 2011 08:11:17 +0100
On 09.12.2011, at 07:55, Ken Thomases wrote:
> On Dec 8, 2011, at 11:18 PM, Abdul Sowayan wrote:
>> The above will still work in an ARC environment. It is rather inefficient, however. For details please check the "Double Check Locking Optimization pattern":
>> http://www.cs.wustl.edu/~schmidt/PDF/DC-Locking.pdf
>
> Double-checked locking is broken. It is an anti-pattern in many languages, including the C family under most common implementations. Don't use it. Google it if you want to confirm. One reference: <http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html>.
Is this an issue that just exists when you want to write against ANSI C, or is this an actual, practical concern when writing on the Mac, for MacOS or iOS? Does anyone have information on the actual memory model implemented in Mac C, ObjC and C++ compilers that reinforce this?
Just trying to figure out whether I have to change a lot of existing Mac and iOS code now, or whether it suffices to be aware of the problem and not write it in new code and stuff that gets ported.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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