diff options
author | Matt Joiner <anacrolix@gmail.com> | 2020-10-02 17:35:11 +1000 |
---|---|---|
committer | Matt Joiner <anacrolix@gmail.com> | 2020-10-02 17:35:11 +1000 |
commit | c35a2c748c6ad053344c9f15f6f86246e48628e0 (patch) | |
tree | e33b8b691286fb48dd637d47589c4e163af62495 /var.go | |
parent | Use builtin eq var in rate and stmutil (diff) | |
download | stm-c35a2c748c6ad053344c9f15f6f86246e48628e0.tar.gz stm-c35a2c748c6ad053344c9f15f6f86246e48628e0.tar.xz |
Only wake Tx if they're still reading a modified value
Diffstat (limited to 'var.go')
-rw-r--r-- | var.go | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -27,9 +27,11 @@ func (v *Var) wakeWatchers(new VarValue) { // We have to lock here to ensure that the Tx is waiting before we signal it. Otherwise we // could signal it before it goes to sleep and it will miss the notification. tx.mu.Lock() - tx.cond.Broadcast() - for !tx.waiting && !tx.completed { - tx.cond.Wait() + if read := tx.reads[v]; read != nil && read.Changed(new) { + tx.cond.Broadcast() + for !tx.waiting && !tx.completed { + tx.cond.Wait() + } } tx.mu.Unlock() return !v.value.Load().(VarValue).Changed(new) |