Am 26.04.2017 um 01:11 schrieb Charles Srstka <[email protected]>:

> From the linked post:
> 
>> The performance penality is also much overblown, as people usually assume 
>> that it is using a full blown mutex - which it is not. Unfortunately, the 
>> situation is so bad that even GCC got it wrong (reported by me here).
> 
> Have to disagree with this statement. I have, more than once, spent some time 
> tracking down severe performance issues in Pacifist, only to have it turn out 
> that the problem was caused by an atomic property being accessed in a loop.

Can you give an example here? I'd really like to see this. Also, that still 
does not change the fact that nonatomic is even unsafe in single-threaded code. 
Just writing the getter yourself as return [[foo retain] autorelease] already 
gets rid of the spinlock, while not having the unsafe side-effects of nonatomic.

> In general, if a property might be changed while another thread is trying to 
> access it, that’s something you should be aware of when designing the class, 
> because a lot of the time, individual atomic properties aren’t going to solve 
> all your threading issues on their own.

True, but this is not what the post is about. The post is about that you want 
the retain and autorelease behavior that atomic is providing, which is missing 
with nonatomic.

> And if the class *isn’t* going to be accessed from multiple threads at once, 
> there’s no point taking the performance hit.

Ok, now I'm starting to wonder: Is the blog post truncated since you're the 
second person who didn't take the second part of the post into consideration? 
It renders fine for me, though. Anyway, the entire second part is about that 
there *is* a point in using atomic, and that it's *not* (only) thread-safety. 
It's that you really want the retain + autorelease behaviour.

> There’s a reason that the “atomic properties” feature wasn’t included in 
> Swift.

I'm not aware of the details in Swift. But I assume in Swift they are always 
retained and autoreleased?

--
Jonathan
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/objc-language/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to