Use custom atomic.Bool, as it is not supported in Go 1.18
This commit is contained in:
+4
-4
@@ -2,16 +2,16 @@ package utils
|
||||
|
||||
import "sync/atomic"
|
||||
|
||||
type AtomicBool struct{ flag int32 }
|
||||
type AtomicBool struct{ flag uint32 }
|
||||
|
||||
func (b *AtomicBool) Get() bool {
|
||||
return atomic.LoadInt32(&(b.flag)) != 0
|
||||
return atomic.LoadUint32(&(b.flag)) != 0
|
||||
}
|
||||
|
||||
func (b *AtomicBool) Set(value bool) {
|
||||
var i int32 = 0
|
||||
var i uint32 = 0
|
||||
if value {
|
||||
i = 1
|
||||
}
|
||||
atomic.StoreInt32(&(b.flag), i)
|
||||
atomic.StoreUint32(&(b.flag), i)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user