Expor AtomicFlag type

This commit is contained in:
Kristóf Tóth 2020-08-18 12:30:39 +02:00
parent 9fd5c8af53
commit 8222f24fa7
1 changed files with 5 additions and 5 deletions

View File

@ -5,22 +5,22 @@ import (
) )
type atomicflag struct { type AtomicFlag struct {
value bool value bool
mutex sync.RWMutex mutex sync.RWMutex
} }
func New(value bool) *atomicflag { func New(value bool) *AtomicFlag {
return &atomicflag{value: value} return &AtomicFlag{value: value}
} }
func (f* atomicflag) Get() bool { func (f *AtomicFlag) Get() bool {
f.mutex.RLock() f.mutex.RLock()
defer f.mutex.RUnlock() defer f.mutex.RUnlock()
return f.value return f.value
} }
func (f* atomicflag) Set(value bool) { func (f *AtomicFlag) Set(value bool) {
f.mutex.Lock() f.mutex.Lock()
defer f.mutex.Unlock() defer f.mutex.Unlock()
f.value = value f.value = value