Re: nonatomic vs atomic assign/retain
Re: nonatomic vs atomic assign/retain
- Subject: Re: nonatomic vs atomic assign/retain
- From: Thomas Davie <email@hidden>
- Date: Tue, 06 Sep 2011 16:49:53 +0100
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.
2) When multithreading you rarely if ever actually want atomicity at the property level, instead you want somewhat larger critical sections in general. Because of that, atomic setters/getters are pointless cruft and everything should be made monatomic.
Chose which camp you live in.
Tom Davie
if (*ra4 != 0xffc78948) { return false; }
On 6 Sep 2011, at 16:30, Torsten Curdt wrote:
> On iOS properties are usually (unless required otherwise) defined as nonatomic
>
> @property (nonatomic, assign)
>
> On the Mac I have seen quite often just an "assign" or "retain" which
> AFAIK defaults to "atomic"
>
> @property (assign)
>
> So what should one use e.g. for normal IBOutlets with AppKit?
> I would think "nonatomic" should be good enough on Mac, too. No?
>
> cheers,
> Torsten
> _______________________________________________
>
> 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
_______________________________________________
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