facet-on-end-of-turn!
This commit is contained in:
parent
cce81dc104
commit
52362a9183
|
@ -24,6 +24,7 @@
|
|||
facet-parent
|
||||
facet-live?
|
||||
facet-inert?
|
||||
facet-on-end-of-turn!
|
||||
facet-on-stop!
|
||||
facet-prevent-inert-check!
|
||||
*dead-facet*
|
||||
|
@ -96,6 +97,7 @@
|
|||
parent
|
||||
children
|
||||
outbound
|
||||
[end-of-turn-actions #:mutable]
|
||||
[shutdown-actions #:mutable]
|
||||
[live? #:mutable]
|
||||
[inert-check-preventers #:mutable])
|
||||
|
@ -144,6 +146,7 @@
|
|||
(make-hasheq)
|
||||
(make-hash)
|
||||
'()
|
||||
'()
|
||||
#f
|
||||
0))
|
||||
|
||||
|
@ -212,12 +215,16 @@
|
|||
(make-hasheq)
|
||||
initial-assertions
|
||||
'()
|
||||
'()
|
||||
#t
|
||||
0))
|
||||
(when parent
|
||||
(hash-set! (facet-children parent) f #t))
|
||||
f)
|
||||
|
||||
(define (facet-on-end-of-turn! f action)
|
||||
(set-facet-end-of-turn-actions! f (cons action (facet-end-of-turn-actions f))))
|
||||
|
||||
(define (facet-on-stop! f action)
|
||||
(set-facet-shutdown-actions! f (cons action (facet-shutdown-actions f))))
|
||||
|
||||
|
@ -277,7 +284,13 @@
|
|||
(lambda (turn)
|
||||
(actor-terminate! turn ac e))))])
|
||||
(action turn)
|
||||
(let loop ()
|
||||
(dataflow-repair-damage! (actor-dataflow ac) (lambda (action) (action turn)))
|
||||
(define pending (reverse (facet-end-of-turn-actions f)))
|
||||
(when (pair? pending)
|
||||
(set-facet-end-of-turn-actions! f '())
|
||||
(for [(action (in-list pending))] (action turn))
|
||||
(loop)))
|
||||
(for [((ff qq) (in-hash (turn-queues turn)))]
|
||||
(queue-task! (actor-engine (facet-actor ff))
|
||||
(lambda ()
|
||||
|
|
|
@ -96,8 +96,7 @@
|
|||
(stop-facet this-facet expr ...))
|
||||
|
||||
(define-syntax-rule (on-start expr ...)
|
||||
;; TODO: delay to end of turn (?)
|
||||
(begin expr ...))
|
||||
(facet-on-end-of-turn! this-facet (action () expr ...)))
|
||||
|
||||
(define-syntax-rule (on-stop expr ...)
|
||||
(facet-on-stop! this-facet (action () expr ...)))
|
||||
|
|
Loading…
Reference in New Issue