On Jan 26, 2009, at 14:45, Sean McBride wrote:

On 1/18/09 4:29 PM, Ben Trumbull said:

I mention this because (I'm embarrassed to admit) I never really
thought about this till yesterday. I *think* other design decisions
have made the atomic-ness irrelevant to any of the code I've written,
but now I need to go back and check, especially where Core Data is
involved.

Core Data @dynamic properties are always nonatomic, irrespective of
the property declaration.

Core Data explicitly, intentionally, and states in the documentation,
that you can have any property atomicity you want so long as it's
nonatomic.

Interesting.  I never thought about this either, and was happy to see
this come up.

BTW, continuing the theme of things I didn't think about ...

Although the rationale for non-atomicity runs under the general thread- safety discussion umbrella, there are actually two separate issues to consider.

Generally, discussion about thread-safety of data like Core Data properties centers around the possibility of conflicting changes from multiple threads. Atomicity at the property level doesn't really help with that (as stated), and the problem must be solved at a higher level.

However, even if only one thread can be changing the data, atomicity still matters. If the accessors aren't atomic, multiple read-only users of the data (in different threads) might get completely bogus results. This problem *can* be solved by atomicity at the property level, if you're prepared to take the potential performance hit from implementing it.

I have to keep reminding myself that serializing changes through a single thread does *not* provide thread safety unless there is atomicity too.


_______________________________________________

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

Reply via email to