navidrome/utils/atomic.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
271 B
Go
Raw Normal View History

2020-07-24 21:40:27 +02:00
package utils
import "sync/atomic"
type AtomicBool struct{ flag uint32 }
2020-07-24 21:40:27 +02:00
func (b *AtomicBool) Get() bool {
return atomic.LoadUint32(&(b.flag)) != 0
2020-07-24 21:40:27 +02:00
}
func (b *AtomicBool) Set(value bool) {
var i uint32 = 0
2020-07-24 21:40:27 +02:00
if value {
i = 1
}
atomic.StoreUint32(&(b.flag), i)
2020-07-24 21:40:27 +02:00
}