From 6a0bcb1246ae5eef854c72d3ff6250ee339d5c94 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Thu, 3 Jun 2021 22:50:37 +0200 Subject: [PATCH] Make box-and-client work better with raco test --- syndicate-examples/box-and-client.rkt | 39 ++++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/syndicate-examples/box-and-client.rkt b/syndicate-examples/box-and-client.rkt index 02deb97..62c12f5 100644 --- a/syndicate-examples/box-and-client.rkt +++ b/syndicate-examples/box-and-client.rkt @@ -4,23 +4,24 @@ (struct set-box (new-value) #:prefab) (struct box-state (value) #:prefab) -(actor-system/dataspace (ds) - (spawn #:name 'box - (define-field current-value 0) - (at ds - (assert (box-state (current-value))) - (when (message (set-box $new-value)) - (log-info "box: taking on new-value ~v" new-value) - (current-value new-value))) - (stop-when-true (= (current-value) 10) - (log-info "box: terminating"))) +(module+ main + (actor-system/dataspace (ds) + (spawn #:name 'box + (define-field current-value 0) + (at ds + (assert (box-state (current-value))) + (when (message (set-box $new-value)) + (log-info "box: taking on new-value ~v" new-value) + (current-value new-value))) + (stop-when-true (= (current-value) 10) + (log-info "box: terminating"))) - (spawn #:name 'client - (at ds - (stop-when (retracted (Observe (:pattern (set-box ,_)) _)) - (log-info "client: box has gone")) - (when (asserted (box-state $v)) - (log-info "client: learned that box's value is now ~v" v) - (send! ds (set-box (+ v 1)))) - (when (retracted (box-state _)) - (log-info "client: box state disappeared"))))) + (spawn #:name 'client + (at ds + (stop-when (retracted (Observe (:pattern (set-box ,_)) _)) + (log-info "client: box has gone")) + (when (asserted (box-state $v)) + (log-info "client: learned that box's value is now ~v" v) + (send! ds (set-box (+ v 1)))) + (when (retracted (box-state _)) + (log-info "client: box state disappeared"))))))