From: Dmitriy Vyukov Date: Mon, 14 May 2012 15:27:29 +0000 (+0400) Subject: sync: use atomic.Store in Once.Do X-Git-Tag: go1.1rc2~3217 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8c4c6c413facabf44b3ecd1fc44bd887fc710271;p=gostls13.git 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 --- diff --git a/src/pkg/sync/once.go b/src/pkg/sync/once.go index 04b714a3e7..1699e86a9e 100644 --- a/src/pkg/sync/once.go +++ b/src/pkg/sync/once.go @@ -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) } }