diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-12 03:01:24 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-12 03:18:40 +0900 |
| commit | 7a2bc2cada971c7a390d09b0afda34780ff56fb6 (patch) | |
| tree | caa19fa8bf404a854c9e2cdf6eb08194e1733a6f /src/atomicbool.go | |
| parent | 9dbf6b02d24b52ae43e36905bbb1e83087e1dfe9 (diff) | |
| download | fzf-7a2bc2cada971c7a390d09b0afda34780ff56fb6.tar.gz | |
Lint
Diffstat (limited to 'src/atomicbool.go')
| -rw-r--r-- | src/atomicbool.go | 5 |
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() |
