aboutsummaryrefslogtreecommitdiff
path: root/var.go
diff options
context:
space:
mode:
Diffstat (limited to 'var.go')
-rw-r--r--var.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/var.go b/var.go
index f3b8d40..3f43096 100644
--- a/var.go
+++ b/var.go
@@ -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)