Re: nonatomic vs atomic assign/retain
Re: nonatomic vs atomic assign/retain
- Subject: Re: nonatomic vs atomic assign/retain
- From: Joar Wingfors <email@hidden>
- Date: Tue, 06 Sep 2011 09:09:31 -0700
On 6 sep 2011, at 08:49, Thomas Davie wrote:
> There are two schools of thought on atomic/nonatomic, and both apply equally to Mac/iOS:
>
> 1) Atomicity provides a little bit of safety, and shouldn't be shrugged off for no reason. Because of that, only optimise the atomic set/get when you've actually profiled and determined it's a problem.
There's an additional consideration to keep in mind - @synthesized getters use the retain+autorelease pattern which makes local variables acquired from such getters "safer" in certain (unusual) usage patterns. Nothing to do with thread safety - of course.
> 2) When multithreading you rarely if ever actually want atomicity at the property level, instead you want somewhat larger critical sections in general.
Wholeheartedly agree.
j o a r
_______________________________________________
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