Repair incorrect interleaving of actions and scripts

This commit is contained in:
Tony Garnock-Jones 2018-04-30 22:47:25 +01:00
parent 3c4076287e
commit f3ca2b6a15
2 changed files with 31 additions and 2 deletions

View File

@ -367,7 +367,8 @@
[(quit)
(apply-patch! ds ac (actor-cleanup-changes ac))]
[(deferred-turn k)
(push-script! ac k)]))))
(push-script! ac k)])
(run-all-pending-scripts! ds))))
(define (apply-patch! ds ac delta)
(define ds-assertions (dataspace-assertions ds))
@ -389,7 +390,8 @@
;; TODO: figure out when a dataspace should quit itself. Given the
;; mutable nature of the implementation, maybe never? It might be
;; being held elsewhere!
(not (null? (dataspace-runnable ds))))
(not (and (null? (dataspace-runnable ds))
(queue-empty? (dataspace-pending-actions ds)))))
(define (add-facet! where actor parent boot-proc)
(when (and (not (in-script?)) where)

View File

@ -0,0 +1,27 @@
#lang imperative-syndicate/test-implementation
(test-case
[(message-struct toggle ())
(spawn* #:name 'flip-flop
(define (even)
(react (stop-when (message (toggle)) (odd))
(on-start (printf "+even\n"))
(on-stop (printf "-even\n"))))
(define (odd)
(react (stop-when (message (toggle)) (even))
(on-start (printf "+odd\n"))
(on-stop (printf "-odd\n"))))
(even))
(spawn* #:name 'main
(until (asserted (observe (toggle))))
(send! (toggle))
(send! (toggle))
(send! (toggle)))]
no-crashes
(expected-output "+even"
"-even"
"+odd"
"-odd"
"+even"
"-even"
"+odd"))