GC and atomic getters/setters
GC and atomic getters/setters
- Subject: GC and atomic getters/setters
- From: BJ Homer <email@hidden>
- Date: Sat, 17 Oct 2009 09:38:25 -0600
In the Garbage Collection Programming Guide: Architecture [1], an example is
given of a set of non-GC getters and setters which use @synchronized(self)
to control the access to the ivar, and in the setter to protect the
releasing of the old object and retaining of the new. Then, a GC example is
given in which the getters and setters have no synchronization; the getter
simply returns the value, and the setter simply assigns the new value.
I understand why the setter is so much simpler under GC; no retain/release
fiddling is necessary. However, I'm confused about the lack of
synchronization in the GC examples. I know there's lots of skepticism as to
whether synchronization at the getter/setter level is even useful (hence the
general recommendation to make properties nonatomic). But assuming that you
wanted it there in the first place, why does the GC version not need the
synchronization? Is it simply because the setter is doing less, and thus
the getter wouldn't ever catch the setter halfway through its setting?
(After releaseing the old value, but before retaining the new, for
example.)
-BJ
[1]
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcArchitecture.html#//apple_ref/doc/uid/TP40002451
_______________________________________________
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