Current implementation of watch uses the fourth argument of the watch callback to update its state. It is wrong, because references do not enforce an execution order on watches : if threads t1 and t2 update the same atom in state x with respectively f1 and f2 such that new state is (f2 (f1 x)), then a watch on this atom may serialize watch callbacks as t2 -> t1 and therefore discard (f2 (f1 x)), leaving final state to (f1 x).
Repro : should always return 2, but currently non-deterministically returns 1 or 2.
Current implementation of
watch
uses the fourth argument of the watch callback to update its state. It is wrong, because references do not enforce an execution order on watches : if threadst1
andt2
update the same atom in statex
with respectivelyf1
andf2
such that new state is(f2 (f1 x))
, then a watch on this atom may serialize watch callbacks ast2
->t1
and therefore discard(f2 (f1 x))
, leaving final state to(f1 x)
.Repro : should always return
2
, but currently non-deterministically returns1
or2
.A correct implementation of
watch
should ignore the value passed to the callback and deref on transfer.