kde-lockscreen-suspend-display/atomicflag/atomicflag.go

28 lines
366 B
Go

package atomicflag
import (
"sync"
)
type AtomicFlag struct {
value bool
mutex sync.RWMutex
}
func New(value bool) *AtomicFlag {
return &AtomicFlag{value: value}
}
func (f *AtomicFlag) Get() bool {
f.mutex.RLock()
defer f.mutex.RUnlock()
return f.value
}
func (f *AtomicFlag) Set(value bool) {
f.mutex.Lock()
defer f.mutex.Unlock()
f.value = value
}