> On Dec 1, 2016, at 4:55 PM, Jiho Choi via swift-dev <swift-dev@swift.org> 
> wrote:
> 
> Thanks for the explanation.
> One last question is why non-atomic ARC operations still use atomic load and 
> store.  Wouldn't regular memory operations be enough?

According to the C++ memory model, all operations on an atomic<T> must be 
atomic. It is undefined behavior to cast a pointer to the atomic into a T* and 
perform normal loads and stores. "Relaxed" loads and stores however imply no 
ordering with other threads, so compile down to plain nonatomic CPU 
instructions.

-Joe
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Reply via email to