Stop a new facet with no endpoints. Fixes #18.

This commit is contained in:
Tony Garnock-Jones 2017-07-12 11:12:10 -04:00
parent 6db1e67a7e
commit 46e5922dc8
2 changed files with 14 additions and 1 deletions

View File

@ -990,7 +990,9 @@
(lookup-facet fid)
(patch (actor-state-knowledge (current-actor-state)) trie-empty)
#t)
(when (and (facet-live? fid) (pair? parent-fid) (not (facet-live? parent-fid)))
(when (and (facet-live? fid)
(or (and (pair? parent-fid) (not (facet-live? parent-fid)))
(hash-empty? (facet-endpoints (lookup-facet fid)))))
(terminate-facet! fid)))
;; If the named facet is live, terminate it.

View File

@ -0,0 +1,11 @@
#lang syndicate/actor
;; Demonstrates that facets with no endpoints don't outlive their `add-facet!` call.
;; This actor will have two facets briefly, before dropping to one:
(spawn (on-start (react (on-start (printf "Hi 1!\n"))
(on-stop (printf "Bye 1!\n"))))
(assert 'x))
;; This actor will have one facet briefly, before dropping to zero and terminating:
(spawn (on-start (printf "Hi 2!\n"))
(on-stop (printf "Bye 2!\n")))