chore: add more tests (#3187)

This commit is contained in:
Kevin Wan
2023-04-29 22:59:07 +08:00
committed by GitHub
parent 14caf5c799
commit a31256b327
4 changed files with 42 additions and 1 deletions

View File

@@ -20,12 +20,14 @@ func ForAtomicBool(val bool) *AtomicBool {
// CompareAndSwap compares current value with given old, if equals, set to given val.
func (b *AtomicBool) CompareAndSwap(old, val bool) bool {
var ov, nv uint32
if old {
ov = 1
}
if val {
nv = 1
}
return atomic.CompareAndSwapUint32((*uint32)(b), ov, nv)
}