mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-21 12:28:39 +00:00
syncs: add AtomicBool
This commit is contained in:
parent
7247e896b5
commit
d3134ad0c8
@ -64,3 +64,18 @@ func (wg *WaitGroupChan) Decr() {
|
||||
|
||||
// Wait blocks until the WaitGroupChan counter is zero.
|
||||
func (wg *WaitGroupChan) Wait() { <-wg.done }
|
||||
|
||||
// AtomicBool is an atomic boolean.
|
||||
type AtomicBool int32
|
||||
|
||||
func (b *AtomicBool) Set(v bool) {
|
||||
var n int32
|
||||
if v {
|
||||
n = 1
|
||||
}
|
||||
atomic.StoreInt32((*int32)(b), n)
|
||||
}
|
||||
|
||||
func (b *AtomicBool) Get() bool {
|
||||
return atomic.LoadInt32((*int32)(b)) != 0
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user