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 }