From b4e2e2802785bb189f073433a446c635c100b101 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sat, 21 Jun 2014 07:29:21 -0400 Subject: [PATCH] Introduce step-process (as composition of deliver-event and apply-transition) --- minimart/core.rkt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/minimart/core.rkt b/minimart/core.rkt index e8f7efe..32526af 100644 --- a/minimart/core.rkt +++ b/minimart/core.rkt @@ -276,6 +276,12 @@ (queue-empty? (world-process-actions w)) (set-empty? (world-runnable-pids w)))) +;; Event PID Process World -> World +;; Delivers the event to the process, then applies the resulting +;; transition, updating the world. +(define (step-process e pid p w) + (apply-transition pid (deliver-event e pid p) w)) + ;; Event PID Process -> Transition ;; Delivers the event to the process, catching any exceptions it ;; throws and converting them to quit Actions. @@ -451,8 +457,7 @@ [(message body meta-level feedback?) (define pids (gestalt-match-value (world-partial-gestalt w) body meta-level feedback?)) (define pt (world-process-table w)) - (for/fold ([w w]) [(pid (in-set pids))] - (apply-transition pid (deliver-event e pid (hash-ref pt pid)) w))] + (for/fold ([w w]) [(pid (in-set pids))] (step-process e pid (hash-ref pt pid) w))] [(pending-routing-update g affected-subgestalt known-target) (define affected-pids (gestalt-match affected-subgestalt g)) (define pt (world-process-table w)) @@ -460,8 +465,7 @@ [(pid (in-set (if known-target (set-add affected-pids known-target) affected-pids)))] (match (hash-ref pt pid (lambda () #f)) [#f w] - [p (define g1 (gestalt-filter g (process-gestalt p))) - (apply-transition pid (deliver-event (routing-update g1) pid p) w)]))])) + [p (step-process (routing-update (gestalt-filter g (process-gestalt p))) pid p w)]))])) ;; World -> Transition ;; Polls the non-provably-inert processes identified by the @@ -478,7 +482,7 @@ (transition (for/fold ([w (struct-copy world w [runnable-pids (set)])]) [(pid (in-set runnable-pids))] (define p (hash-ref (world-process-table w) pid (lambda () #f))) - (if (not p) w (apply-transition pid (deliver-event #f pid p) w))) + (if (not p) w (step-process #f pid p w))) '()))) ;; world needs another check to see if more can happen. ;; Behavior :> (Option Event) World -> Transition