From 91c2d6a3c7bf1e96fbb57957526707d18c5ec739 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Fri, 11 Dec 2015 17:55:46 +1300 Subject: [PATCH] box-and-client actor example --- prospect/examples/actor/box-and-client.rkt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 prospect/examples/actor/box-and-client.rkt diff --git a/prospect/examples/actor/box-and-client.rkt b/prospect/examples/actor/box-and-client.rkt new file mode 100644 index 0000000..7c576ab --- /dev/null +++ b/prospect/examples/actor/box-and-client.rkt @@ -0,0 +1,22 @@ +#lang prospect +;; Simple mutable box and count-to-infinity box client. + +(require prospect/actor) + +(struct set-box (new-value) #:transparent) +(struct box-state (value) #:transparent) + +(%%boot + (lambda () + (actor + + (actor (forever #:collect [(current-value 0)] + (assert (box-state current-value)) + (on (message (set-box $new-value)) + (log-info "box: taking on new-value ~v" new-value) + new-value))) + + (actor (forever (on (asserted (box-state $v)) + (log-info "client: learned that box's value is now ~v" v) + (send! (set-box (+ v 1)))))) + )))