mirror of https://github.com/junegunn/fzf
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
426 B
Go
28 lines
426 B
Go
package fzf
|
|
|
|
import "sync"
|
|
|
|
type AtomicBool struct {
|
|
mutex sync.Mutex
|
|
state bool
|
|
}
|
|
|
|
func NewAtomicBool(initialState bool) *AtomicBool {
|
|
return &AtomicBool{
|
|
mutex: sync.Mutex{},
|
|
state: initialState}
|
|
}
|
|
|
|
func (a *AtomicBool) Get() bool {
|
|
a.mutex.Lock()
|
|
defer a.mutex.Unlock()
|
|
return a.state
|
|
}
|
|
|
|
func (a *AtomicBool) Set(newState bool) bool {
|
|
a.mutex.Lock()
|
|
defer a.mutex.Unlock()
|
|
a.state = newState
|
|
return a.state
|
|
}
|