diff options
author | lukechampine <luke.champine@gmail.com> | 2016-03-30 17:05:31 -0400 |
---|---|---|
committer | lukechampine <luke.champine@gmail.com> | 2016-03-30 17:05:31 -0400 |
commit | c3edf31616f3ef8f770999eded6ee42ccf37f191 (patch) | |
tree | 922b1df6d7aa6a2bc73f35b38d60832d6a260028 /stm.go | |
parent | add LICENSE and shorten README (diff) | |
download | stm-c3edf31616f3ef8f770999eded6ee42ccf37f191.tar.gz stm-c3edf31616f3ef8f770999eded6ee42ccf37f191.tar.xz |
change Get/Set to AtomicGet/Set
Diffstat (limited to 'stm.go')
-rw-r--r-- | stm.go | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -213,18 +213,16 @@ retry: globalLock.Unlock() } -// Get is a helper transaction that reads a value. -func Get(v *Var, recv *interface{}) func(*Tx) { - return func(tx *Tx) { - *recv = tx.Get(v) - } +// AtomicGet is a helper function that atomically reads a value. +func AtomicGet(v *Var) interface{} { + var i interface{} + Atomically(func(tx *Tx) { i = tx.Get(v) }) + return i } -// Set is a helper transaction that writes a value. -func Set(v *Var, val interface{}) func(*Tx) { - return func(tx *Tx) { - tx.Set(v, val) - } +// AtomicSet is a helper function that atomically writes a value. +func AtomicSet(v *Var, val interface{}) { + Atomically(func(tx *Tx) { tx.Set(v, val) }) } // Compose is a helper function that composes multiple transactions into a |