Expor AtomicFlag type

This commit is contained in:
Kristóf Tóth 2020-08-18 12:30:39 +02:00
parent 9fd5c8af53
commit 8222f24fa7

View File

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