Allow multiple "root" facets, by creating a dummy root

This commit is contained in:
Tony Garnock-Jones 2018-05-01 22:39:02 +01:00
parent c85f05ced1
commit 669122766d
1 changed files with 13 additions and 4 deletions

View File

@ -265,11 +265,17 @@
['absent->present (add-assertion! (dataspace-routing-table ds) a)]
;; 'absent->absent and 'present->absent absurd
['present->present (void)])) ;; i.e. no visible change
;; Root facet is a dummy "system" facet that exists to hold one-or-more "user" "root" facets.
(add-facet! #f
the-actor
#f
(lambda ()
(boot-proc)
;; The "true root", user-visible facet.
(add-facet! #f
the-actor
(current-facet)
(lambda ()
(boot-proc)))
(for [(a filtered-initial-assertions)]
(adhoc-retract! the-actor a)))))
@ -410,9 +416,12 @@
(set-facet-children! parent (set-add (facet-children parent) f))
(begin
(when (actor-root-facet actor)
;; TODO: consider whether this is legit. For example, (stop-facet the-root-facet
;; (react ...) (react ...)) should probably be admissible, so perhaps more than one
;; root facet should be allowed?
;; This should never happen. We deliberately create an
;; otherwise-dummy root facet for each actor specifically to
;; hold user facets, and there should be no way for the user
;; to stop that root facet explicitly, which means user code
;; can't start any replacements for it at all, let alone
;; more than one!
(error 'add-facet! "INTERNAL ERROR: Attempt to add second root facet"))
(set-actor-root-facet! actor f)))
(with-current-facet [f]