summaryrefslogtreecommitdiffstats
path: root/vendor/go.uber.org/atomic/atomic.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/go.uber.org/atomic/atomic.go')
-rw-r--r--vendor/go.uber.org/atomic/atomic.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/vendor/go.uber.org/atomic/atomic.go b/vendor/go.uber.org/atomic/atomic.go
index 1db6849f..ad5fa098 100644
--- a/vendor/go.uber.org/atomic/atomic.go
+++ b/vendor/go.uber.org/atomic/atomic.go
@@ -250,11 +250,16 @@ func (b *Bool) Swap(new bool) bool {
// Toggle atomically negates the Boolean and returns the previous value.
func (b *Bool) Toggle() bool {
- return truthy(atomic.AddUint32(&b.v, 1) - 1)
+ for {
+ old := b.Load()
+ if b.CAS(old, !old) {
+ return old
+ }
+ }
}
func truthy(n uint32) bool {
- return n&1 == 1
+ return n == 1
}
func boolToInt(b bool) uint32 {