Commit 8c4c6c41 authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

sync: use atomic.Store in Once.Do

No perf/semantic changes, merely improves code health.
There were several questions as to why Once.Do uses
atomic.CompareAndSwap to do a store.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6208057
parent 58bcec62
......@@ -38,6 +38,6 @@ func (o *Once) Do(f func()) {
defer o.m.Unlock()
if o.done == 0 {
f()
atomic.CompareAndSwapUint32(&o.done, 0, 1)
atomic.StoreUint32(&o.done, 1)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment