2021-06-03 20:54:36 +00:00
|
|
|
#lang syndicate
|
2021-05-27 09:28:10 +00:00
|
|
|
|
2021-06-03 21:22:46 +00:00
|
|
|
(require "protocol.rkt")
|
|
|
|
(require "stats.rkt")
|
2021-05-28 07:57:11 +00:00
|
|
|
|
2021-06-01 08:04:10 +00:00
|
|
|
(define box
|
|
|
|
(action (ds LIMIT REPORT_EVERY)
|
2021-06-03 15:01:59 +00:00
|
|
|
(spawn #:name 'box
|
2021-06-01 08:04:10 +00:00
|
|
|
(define-field value 0)
|
2021-06-03 15:01:59 +00:00
|
|
|
(define reporter (report-stats REPORT_EVERY))
|
2021-06-01 08:04:10 +00:00
|
|
|
(at ds
|
2021-06-02 11:11:26 +00:00
|
|
|
(assert (BoxState (value)))
|
|
|
|
(when (message (SetBox $new-value))
|
2021-06-03 15:01:59 +00:00
|
|
|
(reporter new-value)
|
2021-06-03 21:22:46 +00:00
|
|
|
(when (= new-value LIMIT) (stop-current-facet))
|
2021-06-01 08:04:10 +00:00
|
|
|
(value new-value))))))
|
|
|
|
|
|
|
|
(define client
|
|
|
|
(action (ds)
|
2021-06-03 15:01:59 +00:00
|
|
|
(spawn #:name 'client
|
|
|
|
(define root-facet this-facet)
|
2021-06-01 08:04:10 +00:00
|
|
|
(at ds
|
2021-06-03 14:07:25 +00:00
|
|
|
(when (asserted (BoxState $value)) (send! ds (SetBox (+ value 1))))
|
2021-06-03 14:03:00 +00:00
|
|
|
(during (BoxState _)
|
|
|
|
(on-stop (log-info "Client detected box termination")
|
|
|
|
(stop-facet root-facet)))))))
|
2021-05-28 07:57:11 +00:00
|
|
|
|
2021-05-31 11:07:37 +00:00
|
|
|
(module+ main
|
|
|
|
(time
|
2021-06-03 20:40:51 +00:00
|
|
|
(actor-system/dataspace (ds)
|
|
|
|
(box this-turn ds 500000 100000)
|
|
|
|
(client this-turn ds))))
|