If I understand correctly the two complementary Load/Store methods behave conceptually as a volatile variable in say Java. A memory barrier is inserted in the correct location respectively thus ensuring memory coherence across goroutines (really the underlying threads and cpus).
Reading shared variables like you do in your code is afaik not guaranteed to yield consistent results under the go memory model as per specification.
As for not using swap, well I guess there is no need to swap anything with only one producer?
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Thanks for the answer. It leaves me with a few follow-ups:Can you explain why it breaks in the memory model?
Also, why do StorePoitner and LoadPointer instead of CompareAndSwap?