github.com/hdt3213/godis@v1.2.9/lib/sync/atomic/bool.go (about) 1 package atomic 2 3 import "sync/atomic" 4 5 // Boolean is a boolean value, all actions of it is atomic 6 type Boolean uint32 7 8 // Get reads the value atomically 9 func (b *Boolean) Get() bool { 10 return atomic.LoadUint32((*uint32)(b)) != 0 11 } 12 13 // Set writes the value atomically 14 func (b *Boolean) Set(v bool) { 15 if v { 16 atomic.StoreUint32((*uint32)(b), 1) 17 } else { 18 atomic.StoreUint32((*uint32)(b), 0) 19 } 20 }