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

28 lines
366 B
Go
Raw Normal View History

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
}