aboutsummaryrefslogtreecommitdiff
path: root/funcs.go
diff options
context:
space:
mode:
authorMatt Joiner <anacrolix@gmail.com>2019-11-05 11:49:42 +1100
committerMatt Joiner <anacrolix@gmail.com>2019-11-05 11:49:42 +1100
commitcc0357f5252666ef67bb8f73f86b47ddbdb245be (patch)
treed32209c3cc4696849b79f245f8f2eef45b034b9d /funcs.go
parentAdd expvars (diff)
downloadstm-cc0357f5252666ef67bb8f73f86b47ddbdb245be.tar.gz
stm-cc0357f5252666ef67bb8f73f86b47ddbdb245be.tar.xz
Optimize AtomicSet
Diffstat (limited to 'funcs.go')
-rw-r--r--funcs.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/funcs.go b/funcs.go
index 3d89cc5..bd7f0e9 100644
--- a/funcs.go
+++ b/funcs.go
@@ -69,9 +69,9 @@ func AtomicGet(v *Var) interface{} {
// AtomicSet is a helper function that atomically writes a value.
func AtomicSet(v *Var, val interface{}) {
- Atomically(func(tx *Tx) {
- tx.Set(v, val)
- })
+ v.mu.Lock()
+ v.changeValue(val)
+ v.mu.Unlock()
}
// Compose is a helper function that composes multiple transactions into a