24 lines
606 B
Racket
24 lines
606 B
Racket
#lang prospect
|
|
|
|
(require prospect/actor)
|
|
|
|
(struct echo-req (body) #:prefab)
|
|
(struct echo-resp (body) #:prefab)
|
|
|
|
(actor-body->spawn-action
|
|
(lambda ()
|
|
(actor (forever #:collect [(count 0)]
|
|
(on (message (echo-req $body))
|
|
(send! (echo-resp body))
|
|
(+ count 1))))
|
|
|
|
(actor (forever (on (message (echo-resp $body))
|
|
(printf "Received: ~v\n" body))))
|
|
|
|
(until (asserted (observe (echo-req _))))
|
|
(until (asserted (observe (echo-resp _))))
|
|
(send! (echo-req 0))
|
|
(send! (echo-req 1))
|
|
(send! (echo-req 2))
|
|
))
|