If a parent facet terminates, its children watch for this and terminate themselves.

This commit is contained in:
Tony Garnock-Jones 2016-05-17 01:15:09 -04:00
parent 1e84a3507d
commit 791d2880ae
1 changed files with 9 additions and 3 deletions

View File

@ -152,7 +152,9 @@
;; - role: Callee
;; Asserts LinkActive while it runs. Should send LinkResult
;; before termination to indicate success and communicate values
;; to Caller.
;; to Caller. Monitors (observe LinkActive) to detect
;; termination of the Caller; upon termination of the Caller,
;; terminates itself.
;;
;; A LinkActive is a (link-active Symbol Symbol), describing an
;; ongoing relationship between the indicated caller and callee.
@ -340,10 +342,13 @@
(define (generic-actor-behavior e s)
(match e
[(? patch/removed? p)
(define caller-id (actor-state-caller-id s))
(define self-id (actor-state-self-id s))
(define continuation-table (actor-state-continuation-table s))
(define quit?
(for/or [(callee-id (trie-project/set/single (patch-removed p) link-active-projection))]
(hash-has-key? continuation-table callee-id)))
(or (trie-lookup (patch-removed p) (observe (link-active caller-id self-id)) #f)
(for/or [(callee-id (trie-project/set/single (patch-removed p) link-active-projection))]
(hash-has-key? continuation-table callee-id))))
(if quit? ;; TODO: raise exception instead? Signal the cause of the quit somehow?
(quit)
#f)]
@ -753,6 +758,7 @@
(define initial-subs
#,(if (eq? linkage-kind 'call)
#`(patch-seq sub-to-callees
(sub (observe (link-active caller-id self-id)))
(core:assert (link-active caller-id self-id)))
#`sub-to-callees))
((extend-pending-patch *linkage-label* initial-subs) s))