aboutsummaryrefslogtreecommitdiff
path: root/funcs.go
diff options
context:
space:
mode:
authorMatt Joiner <anacrolix@gmail.com>2019-11-04 15:14:33 +1100
committerMatt Joiner <anacrolix@gmail.com>2019-11-04 15:14:33 +1100
commit80ec29f423aeb8f7de75c057b12b2e5cd8cb35ba (patch)
tree65b7923b152f9695a0a87dbc26a58bef1d10e29c /funcs.go
parentTransfer project stewardship to anacrolix (diff)
downloadstm-80ec29f423aeb8f7de75c057b12b2e5cd8cb35ba.tar.gz
stm-80ec29f423aeb8f7de75c057b12b2e5cd8cb35ba.tar.xz
Use atomic pointers for Var data
Diffstat (limited to 'funcs.go')
-rw-r--r--funcs.go8
1 files changed, 1 insertions, 7 deletions
diff --git a/funcs.go b/funcs.go
index 47c6273..bd2cf20 100644
--- a/funcs.go
+++ b/funcs.go
@@ -58,13 +58,7 @@ retry:
// AtomicGet is a helper function that atomically reads a value.
func AtomicGet(v *Var) interface{} {
- // since we're only doing one operation, we don't need a full transaction
- globalLock.Lock()
- v.mu.Lock()
- val := v.val
- v.mu.Unlock()
- globalLock.Unlock()
- return val
+ return v.loadState().val
}
// AtomicSet is a helper function that atomically writes a value.