summaryrefslogtreecommitdiff
path: root/src/atomicbool.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-01-12 03:01:24 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-01-12 03:18:40 +0900
commit7a2bc2cada971c7a390d09b0afda34780ff56fb6 (patch)
treecaa19fa8bf404a854c9e2cdf6eb08194e1733a6f /src/atomicbool.go
parent9dbf6b02d24b52ae43e36905bbb1e83087e1dfe9 (diff)
downloadfzf-7a2bc2cada971c7a390d09b0afda34780ff56fb6.tar.gz
Lint
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()