]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modload: convert atomicLoadPkgFlags.bits to atomic type
authorhopehook <hopehook@qq.com>
Thu, 25 Aug 2022 03:11:59 +0000 (11:11 +0800)
committerGopher Robot <gobot@golang.org>
Fri, 26 Aug 2022 17:45:20 +0000 (17:45 +0000)
Change-Id: I9e59530953439dec6f4524c5a7adc75c98c12b8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/425456
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>

src/cmd/go/internal/modload/load.go

index 7e061f01a43b88761edde64ad8cf09a4cf69bc1e..69b0c30978da0e3252330184b92689be349fcec3 100644 (file)
@@ -932,7 +932,7 @@ func (f loadPkgFlags) has(cond loadPkgFlags) bool {
 // An atomicLoadPkgFlags stores a loadPkgFlags for which individual flags can be
 // added atomically.
 type atomicLoadPkgFlags struct {
-       bits int32
+       bits atomic.Int32
 }
 
 // update sets the given flags in af (in addition to any flags already set).
@@ -941,9 +941,9 @@ type atomicLoadPkgFlags struct {
 // flags were newly-set.
 func (af *atomicLoadPkgFlags) update(flags loadPkgFlags) (old loadPkgFlags) {
        for {
-               old := atomic.LoadInt32(&af.bits)
+               old := af.bits.Load()
                new := old | int32(flags)
-               if new == old || atomic.CompareAndSwapInt32(&af.bits, old, new) {
+               if new == old || af.bits.CompareAndSwap(old, new) {
                        return loadPkgFlags(old)
                }
        }
@@ -951,7 +951,7 @@ func (af *atomicLoadPkgFlags) update(flags loadPkgFlags) (old loadPkgFlags) {
 
 // has reports whether all of the flags in cond are set in af.
 func (af *atomicLoadPkgFlags) has(cond loadPkgFlags) bool {
-       return loadPkgFlags(atomic.LoadInt32(&af.bits))&cond == cond
+       return loadPkgFlags(af.bits.Load())&cond == cond
 }
 
 // isTest reports whether pkg is a test of another package.