aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Joiner <anacrolix@gmail.com>2019-11-04 16:23:01 +1100
committerMatt Joiner <anacrolix@gmail.com>2019-11-04 16:23:01 +1100
commit347294ec79f2876be40d0770b31658682bb0de3a (patch)
treede6b669c6edd2357dc4149d3aebb7c99a9583aca
parentRemove global lock (diff)
downloadstm-347294ec79f2876be40d0770b31658682bb0de3a.tar.gz
stm-347294ec79f2876be40d0770b31658682bb0de3a.tar.xz
Reduce transaction locking on Tx.wait
-rw-r--r--tx.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/tx.go b/tx.go
index 72a58b2..45af14d 100644
--- a/tx.go
+++ b/tx.go
@@ -42,17 +42,17 @@ func (tx *Tx) commit() {
// wait blocks until another transaction modifies any of the Vars read by tx.
func (tx *Tx) wait() {
- tx.mu.Lock() // probably can around verify
for v := range tx.reads {
v.watchers.Store(tx, nil)
}
+ tx.mu.Lock()
for tx.verify() {
tx.cond.Wait()
}
+ tx.mu.Unlock()
for v := range tx.reads {
v.watchers.Delete(tx)
}
- tx.mu.Unlock() // move back to verify?
}
// Get returns the value of v as of the start of the transaction.