For example: type Page struct { views uint32 }
func (page *Page) SetViews(n uint32) { atomic.StoreUint32(&page.views, n) } func (page *Page) Views() uint32 { return atomic.LoadUint32(&page.views) } Keith Randall and Ian Lance Taylor said that atomic.Load is a memory_order_acquire <https://groups.google.com/forum/#!topic/golang-nuts/mSD7u1oEhSk> and atomic.Store is memory_order_release <https://groups.google.com/forum/#!topic/golang-nuts/mSD7u1oEhSk>, so there is no memory order guarantees between the following two calls, I think: atomic.StoreUint32(&page.views, n) atomic.LoadUint32(&page.views) In other words, the load result might not reflect the latest value of page.views. On the contrary, the memory order between the following two calls is guaranteed to be as their order shown in code. atomic.LoadUint32(&page.views) atomic.StoreUint32(&page.views, n) Is my understanding right? -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/51583b07-7f1d-4fad-86c6-38a19495b8d7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.