Ensure patched assertions are added before being removed, to avoid glitching
This commit is contained in:
parent
22b4f965b9
commit
bc4fb5ef94
|
@ -458,6 +458,10 @@ check followed by zero or more (move, check) pairs.
|
||||||
removeAssertion :: Index -> V -> 1
|
removeAssertion :: Index -> V -> 1
|
||||||
removeAssertion index v = adjustAssertion index v -1
|
removeAssertion index v = adjustAssertion index v -1
|
||||||
|
|
||||||
|
Care must be taken when applying entire *patches* to ensure that added
|
||||||
|
assertions are processed before removed assertions; otherwise, actors
|
||||||
|
will observe glitching in certain cases.
|
||||||
|
|
||||||
**Definition.** The procedure `sendMessage` delivers a message `v` to
|
**Definition.** The procedure `sendMessage` delivers a message `v` to
|
||||||
event handlers in the given index.
|
event handlers in the given index.
|
||||||
|
|
||||||
|
|
|
@ -368,15 +368,18 @@
|
||||||
;; (for [((a c) (in-bag/count ds-assertions))] (log-info " . ~v = ~v" a c))
|
;; (for [((a c) (in-bag/count ds-assertions))] (log-info " . ~v = ~v" a c))
|
||||||
;; (for [((a c) (in-bag/count delta))] (log-info " → ~v = ~v" a c))
|
;; (for [((a c) (in-bag/count delta))] (log-info " → ~v = ~v" a c))
|
||||||
(define rt (dataspace-routing-table ds))
|
(define rt (dataspace-routing-table ds))
|
||||||
|
(define pending-removals '())
|
||||||
(define new-cleanup-changes
|
(define new-cleanup-changes
|
||||||
(for/fold [(cleanup-changes (actor-cleanup-changes ac))] [((a count) (in-bag/count delta))]
|
(for/fold [(cleanup-changes (actor-cleanup-changes ac))] [((a count) (in-bag/count delta))]
|
||||||
(match (bag-change! ds-assertions a count)
|
(match (bag-change! ds-assertions a count)
|
||||||
['present->absent (remove-assertion! rt a)]
|
['present->absent (set! pending-removals (cons a pending-removals))]
|
||||||
['absent->present (add-assertion! rt a)]
|
['absent->present (add-assertion! rt a)]
|
||||||
;; 'absent->absent absurd
|
;; 'absent->absent absurd
|
||||||
['present->present (void)]) ;; i.e. no visible change
|
['present->present (void)]) ;; i.e. no visible change
|
||||||
(define-values (updated-bag _summary) (bag-change cleanup-changes a (- count)))
|
(define-values (updated-bag _summary) (bag-change cleanup-changes a (- count)))
|
||||||
updated-bag))
|
updated-bag))
|
||||||
|
(for [(a (in-list pending-removals))]
|
||||||
|
(remove-assertion! rt a))
|
||||||
(set-actor-cleanup-changes! ac new-cleanup-changes)))
|
(set-actor-cleanup-changes! ac new-cleanup-changes)))
|
||||||
|
|
||||||
(define (run-scripts! ds)
|
(define (run-scripts! ds)
|
||||||
|
|
|
@ -16,4 +16,6 @@
|
||||||
(log-info "client: box has gone"))
|
(log-info "client: box has gone"))
|
||||||
(on (asserted (box-state $v))
|
(on (asserted (box-state $v))
|
||||||
(log-info "client: learned that box's value is now ~v" v)
|
(log-info "client: learned that box's value is now ~v" v)
|
||||||
(send! (set-box (+ v 1)))))
|
(send! (set-box (+ v 1))))
|
||||||
|
(on (retracted (box-state _))
|
||||||
|
(log-info "client: box state disappeared")))
|
||||||
|
|
Loading…
Reference in New Issue