// 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).
// 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)
}
}
// 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.