stop-actor-system

This commit is contained in:
Tony Garnock-Jones 2021-06-15 14:26:19 +02:00
parent 3fe5d3a343
commit 44bee78044
2 changed files with 18 additions and 2 deletions

View File

@ -45,6 +45,7 @@
turn-facet!
turn-stop!
turn-spawn!
turn-stop-actor-system!
turn-stop-actor!
turn-crash!
turn-field!
@ -196,8 +197,8 @@
(thread-wait (engine-thread e)))
(define (actor-system-shutdown! e)
(for [(ac (in-list (engine-shutdown! e)))]
(actor-terminate! ac #t)))
(define actors (engine-shutdown! e))
(for [(ac (in-list actors))] (actor-terminate! ac #t)))
(define (escape-pod boot-proc #:name [name 'escape-pod])
(define e (actor-engine (facet-actor (turn-active-facet (current-turn)))))
@ -384,6 +385,10 @@
new-facet))
(define (turn-stop! [f (turn-active-facet (current-turn))] [continuation #f])
(when (not (eq? (facet-actor f) (facet-actor (turn-active-facet (current-turn)))))
(error 'turn-stop! "Attempted to stop facet ~v from different actor ~v"
f
(facet-actor (turn-active-facet (current-turn)))))
(log-syndicate/actor-debug " ENQ stop-facet ~v" f)
(turn-enqueue! (current-turn)
f
@ -425,6 +430,13 @@
linked-peer link-message handle)
(deliver (entity-assert link-entity) link-message handle)))))))
(define (turn-stop-actor-system! turn)
(define ac (facet-actor (turn-active-facet turn)))
(log-syndicate/actor-debug " ENQ stop-actor-system ~v" ac)
(turn-enqueue! turn (actor-root ac) (lambda ()
(log-syndicate/actor-debug " DEQ stop-actor-system ~v" ac)
(actor-system-shutdown! (actor-engine ac)))))
(define (turn-stop-actor! turn)
(define ac (facet-actor (turn-active-facet turn)))
(log-syndicate/actor-debug " ENQ stop-actor ~v" ac)

View File

@ -16,6 +16,7 @@
react
let-event
define-field
stop-actor-system
stop-facet
stop-current-facet
on-start
@ -191,6 +192,9 @@
(define-syntax-rule (define-field id initial-value)
(define id (turn-field! this-turn 'id initial-value)))
(define (stop-actor-system)
(turn-stop-actor-system! this-turn))
(define-syntax stop-facet
(syntax-rules ()
[(_ f) (turn-stop! f)]