1
0
mirror of https://github.com/golang/go synced 2024-11-26 16:16:57 -07:00

cmd/go/internal/modload: convert atomicLoadPkgFlags.bits to atomic type

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>
This commit is contained in:
hopehook 2022-08-25 11:11:59 +08:00 committed by Gopher Robot
parent 48ecc152e4
commit 78aef56062

View 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.