From a7b4dec151125aa20d505006aa9d30840b136831 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sat, 24 Mar 2012 16:12:42 -0400 Subject: [PATCH] Add ground spy to example --- os2-example.rkt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/os2-example.rkt b/os2-example.rkt index fba4fbe..f794427 100644 --- a/os2-example.rkt +++ b/os2-example.rkt @@ -23,8 +23,20 @@ (newline) (transition 'no-state (kill))))) +(define spy + (lambda () + (define (hs label) + (define ((w kind) . args) (write `(,label ,kind ,@args)) (newline) values) + (handlers (w 'presence) + (w 'absence) + (w 'message))) + (transition 'spy-state + (add-role (topic-publisher (wild) #:virtual? #t) (hs 'subscriber->publisher)) + (add-role (topic-subscriber (wild) #:virtual? #t) (hs 'publisher->subscriber))))) + (ground-vm (lambda () (transition 'no-state + (spawn spy) (spawn (lambda () (example-process 1000))) (spawn (lambda () (example-process 2000))) (kill))))