2016-07-10 16:33:16 +00:00
|
|
|
#lang syndicate/actor
|
2016-01-14 20:19:00 +00:00
|
|
|
|
|
|
|
(struct echo-req (body) #:prefab)
|
|
|
|
(struct echo-resp (body) #:prefab)
|
|
|
|
|
2017-02-15 23:18:19 +00:00
|
|
|
(spawn (field [count 0])
|
2016-08-24 16:35:38 +00:00
|
|
|
(on (message (echo-req $body))
|
|
|
|
(send! (echo-resp body))
|
|
|
|
(count (+ (count) 1))))
|
2016-01-14 20:19:00 +00:00
|
|
|
|
2017-02-15 23:18:19 +00:00
|
|
|
(spawn (on (message (echo-resp $body))
|
2016-08-24 16:35:38 +00:00
|
|
|
(printf "Received: ~v\n" body)))
|
2016-01-14 20:19:00 +00:00
|
|
|
|
2017-02-15 23:18:19 +00:00
|
|
|
(spawn* (until (asserted (observe (echo-req _))))
|
2016-08-24 16:35:38 +00:00
|
|
|
(until (asserted (observe (echo-resp _))))
|
|
|
|
(send! (echo-req 0))
|
|
|
|
(send! (echo-req 1))
|
|
|
|
(send! (echo-req 2)))
|