From 8c4c6c413facabf44b3ecd1fc44bd887fc710271 Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Mon, 14 May 2012 19:27:29 +0400 Subject: [PATCH] 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 --- src/pkg/sync/once.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkg/sync/once.go b/src/pkg/sync/once.go index 04b714a3e74..1699e86a9eb 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) } }