Re: GC and atomic getters/setters
Re: GC and atomic getters/setters
- Subject: Re: GC and atomic getters/setters
- From: Bill Bumgarner <email@hidden>
- Date: Sat, 17 Oct 2009 09:18:27 -0700
On Oct 17, 2009, at 8:38 AM, BJ Homer wrote:
But assuming that you
wanted it there in the first place, why does the GC version not need
the
synchronization?
Under GC, object reference assignments -- scanned pointer assignments,
technically -- are, in and of themselves, atomic. Note that
structures will still require atomicity protection in GC, if desired
(though, yes, property level atomicity is generally the wrong answer
for ensuring thread safety).
In non-gc, the need to send some combination of -retain/-release/-
autorelease method calls leaves a window within which a caller may get
a hold of an object reference that is about to be released in another
thread. Thus, the need to use some form of locking or synchronization
primitive to ensure that this doesn't happen.
As Kai said, GC's natural atomicity in object assignment is a distinct
advantage. In particular, it makes concurrent programming a bit less
tricky as there is no need to play retain-on-one-thread-to-release-on-
another-thread games.
b.bum
_______________________________________________
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