aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlukechampine <luke.champine@gmail.com>2016-04-03 12:29:48 -0400
committerlukechampine <luke.champine@gmail.com>2016-04-03 12:32:21 -0400
commit65f3b7ebc2ebeca40e07b28b7543c39457ed0831 (patch)
treea867f3ec26b9548e5a786da33ef1926c6d8312f4
parentadd TestSelect and TestCompose (diff)
downloadstm-65f3b7ebc2ebeca40e07b28b7543c39457ed0831.tar.gz
stm-65f3b7ebc2ebeca40e07b28b7543c39457ed0831.tar.xz
fix AtomicSet bug
-rw-r--r--stm.go5
1 files changed, 1 insertions, 4 deletions
diff --git a/stm.go b/stm.go
index 39cdec4..cb745a1 100644
--- a/stm.go
+++ b/stm.go
@@ -230,10 +230,7 @@ func AtomicGet(v *Var) interface{} {
func AtomicSet(v *Var, val interface{}) {
// since we're only doing one operation, we don't need a full transaction
globalLock.Lock()
- v.mu.Lock()
- v.val = val
- v.mu.Unlock()
- globalCond.Broadcast()
+ (&Tx{writes: map[*Var]interface{}{v: val}}).commit()
globalLock.Unlock()
}