From 956a940480959929eb558eb3f0bcf03b31164221 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 10 Aug 2016 19:03:52 -0400 Subject: [PATCH] Cosmetic --- racket/syndicate/examples/actor/queue.rkt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/racket/syndicate/examples/actor/queue.rkt b/racket/syndicate/examples/actor/queue.rkt index ab2fbb3..2eaafb7 100644 --- a/racket/syndicate/examples/actor/queue.rkt +++ b/racket/syndicate/examples/actor/queue.rkt @@ -44,13 +44,10 @@ ;; EFFECT: Spawn a queue process named `queue-id`. (define (spawn-queue queue-id) (actor #:name (list 'queue queue-id) - (react (define/query-hash credits (subscription queue-id $who) who 0) ;; Start with no credit - (field [waiters (make-queue)]) + (react (field [waiters (make-queue)]) (field [messages (make-queue)]) - (during (subscription queue-id $who) - (assert (metric (list 'credit queue-id who) (hash-ref (credits) who 0)))) - (assert (metric (list 'backlog queue-id) (queue-length (messages)))) + (define/query-hash credits (subscription queue-id $who) who 0) ;; Start with no credit (on (message (credit queue-id $who $amount)) (define old-credit (hash-ref (credits) who #f)) @@ -75,6 +72,10 @@ (log-info "~a: sending ~a message ~a" queue-id who msg) (send! (delivery queue-id who msg))))) + (during (subscription queue-id $who) + (assert (metric (list 'credit queue-id who) (hash-ref (credits) who 0)))) + (assert (metric (list 'backlog queue-id) (queue-length (messages)))) + ;;------------------------------------------------------------ (local-require (submod syndicate/actor priorities))