Re: How to implement readonly property
Re: How to implement readonly property
- Subject: Re: How to implement readonly property
- From: Steve Sisak <email@hidden>
- Date: Sat, 08 Dec 2012 14:17:56 -0500
At 10:24 AM -0800 12/8/12, Kyle Sluder wrote:
On Dec 8, 2012, at 10:06 AM, Steve Sisak <email@hidden> wrote:
> Further, if writes were not complete at the end of the block, the
construct would be essentially useless for its intended purpose.
By the way, you're wrong about this too. All @synchronized does is
act as a mutex around a code block. It does not cause the compiler
to reorder instructions and issue memory barriers in such a way that
initialization is guaranteed to precede assignment from the
perspective of all threads.
Please cite a source for this assertion.
From:
<https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/ThreadSafety/ThreadSafety.html>
"If you are already using a mutex to protect a section of code, do
not automatically assume you need to use the volatile keyword to
protect important variables inside that section. A mutex includes a
memory barrier to ensure the proper ordering of load and store
operations."
I acknowledge that, without proper memory barriers, double-checked
locking is problematic, but am providing an example using a construct
which I'm fairly sure uses proper memory barriers.
-Steve
_______________________________________________
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