2016-10-25 16:38:19 +00:00
|
|
|
#lang syndicate/actor
|
2016-10-25 20:59:00 +00:00
|
|
|
;;
|
|
|
|
;; Test case for a problem written up on 25 Oct 2016 in my research
|
|
|
|
;; journal.
|
|
|
|
;;
|
|
|
|
;; When the problem exists, we see only "starting", and not
|
|
|
|
;; "stopping", because by the time the spawn action producing the 'up
|
|
|
|
;; actor is processed, 'up has already been retracted (by the
|
|
|
|
;; termination of 'asserter).
|
|
|
|
;;
|
|
|
|
;; This is an expectation/operation mismatch.
|
|
|
|
;;
|
|
|
|
;; The approach I've chosen is to *label* each instance of a
|
|
|
|
;; `during/actor` using the new syndicate/protocol/instance, and to
|
|
|
|
;; change the lifetime-control protocol between the spawner and
|
|
|
|
;; spawnee to match.
|
|
|
|
;;
|
|
|
|
;; PROBLEM OUTPUT:
|
|
|
|
;;
|
|
|
|
;; got done
|
|
|
|
;; starting
|
|
|
|
;;
|
|
|
|
;; EXPECTED OUTPUT:
|
|
|
|
;;
|
|
|
|
;; got done
|
|
|
|
;; starting
|
|
|
|
;; stopping
|
|
|
|
;;
|
2016-10-25 16:38:19 +00:00
|
|
|
|
|
|
|
(require/activate syndicate/drivers/timer)
|
|
|
|
|
2017-02-15 23:18:19 +00:00
|
|
|
(spawn #:name 'main
|
2016-10-25 16:38:19 +00:00
|
|
|
(on (message 'trigger)
|
2017-02-15 23:18:19 +00:00
|
|
|
(spawn* #:name 'asserter
|
2016-10-25 16:38:19 +00:00
|
|
|
(assert! 'up)
|
|
|
|
(send! 'done)))
|
2017-02-15 23:18:19 +00:00
|
|
|
(during/spawn 'up
|
2016-10-25 16:38:19 +00:00
|
|
|
#:name 'up
|
|
|
|
(on-start (printf "starting\n"))
|
|
|
|
(on-stop (printf "stopping\n"))))
|
|
|
|
|
2017-02-15 23:18:19 +00:00
|
|
|
(spawn* #:name 'triggerer
|
2016-10-25 16:38:19 +00:00
|
|
|
(until (asserted (observe 'trigger)))
|
|
|
|
(send! 'trigger)
|
|
|
|
(until (message 'done))
|
|
|
|
(printf "got done\n")
|
|
|
|
(send! (set-timer 'timer 500 'relative))
|
|
|
|
(until (message (timer-expired 'timer _))))
|