summaryrefslogtreecommitdiff
path: root/src/atomicbool.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/atomicbool.go')
-rw-r--r--src/atomicbool.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/atomicbool.go b/src/atomicbool.go
index f2f4894f..b264724c 100644
--- a/src/atomicbool.go
+++ b/src/atomicbool.go
@@ -2,23 +2,28 @@ package fzf
import "sync"
+// AtomicBool is a boxed-class that provides synchronized access to the
+// underlying boolean value
type AtomicBool struct {
mutex sync.Mutex
state bool
}
+// NewAtomicBool returns a new AtomicBool
func NewAtomicBool(initialState bool) *AtomicBool {
return &AtomicBool{
mutex: sync.Mutex{},
state: initialState}
}
+// Get returns the current boolean value synchronously
func (a *AtomicBool) Get() bool {
a.mutex.Lock()
defer a.mutex.Unlock()
return a.state
}
+// Set updates the boolean value synchronously
func (a *AtomicBool) Set(newState bool) bool {
a.mutex.Lock()
defer a.mutex.Unlock()