Style: use atomic CompareAndSwap (#151)

This commit is contained in:
gVisor bot 2019-03-26 23:48:03 +08:00
parent 041702aac6
commit ebd32c686a

View file

@ -92,7 +92,7 @@ func (u *URLTest) fallback() {
}
func (u *URLTest) speedTest() {
if atomic.AddInt32(&u.once, 1) != 1 {
if atomic.CompareAndSwapInt32(&u.once, 0, 1) {
return
}
defer atomic.StoreInt32(&u.once, 0)