2017-08-10 19:17:28 +00:00
|
|
|
#lang syndicate
|
2016-10-31 21:36:59 +00:00
|
|
|
|
|
|
|
(require/activate syndicate/drivers/timestate)
|
|
|
|
|
2017-02-15 23:18:19 +00:00
|
|
|
(spawn #:name 'demo-timeout
|
2016-10-31 21:36:59 +00:00
|
|
|
(on-start (printf "Starting demo-timeout\n"))
|
|
|
|
(on-stop (printf "Stopping demo-timeout\n"))
|
|
|
|
(stop-when-timeout 3000 (printf "Three second timeout fired\n")))
|
|
|
|
|
2017-02-15 23:18:19 +00:00
|
|
|
(spawn #:name 'demo-later-than
|
2016-10-31 21:36:59 +00:00
|
|
|
(on-start (printf "Starting demo-later-than\n"))
|
|
|
|
(on-stop (printf "Stopping demo-later-than\n"))
|
|
|
|
(field [deadline (+ (current-inexact-milliseconds) 5000)])
|
|
|
|
(stop-when (asserted (later-than (deadline)))
|
|
|
|
(printf "Deadline expired\n")))
|
2016-10-31 21:42:38 +00:00
|
|
|
|
2017-02-15 23:18:19 +00:00
|
|
|
(spawn #:name 'demo-updating-later-than
|
2016-10-31 21:42:38 +00:00
|
|
|
(field [deadline (current-inexact-milliseconds)])
|
|
|
|
(field [counter 0])
|
|
|
|
(on #:when (< (counter) 10) (asserted (later-than (deadline)))
|
|
|
|
(printf "Tick ~v\n" (counter))
|
|
|
|
(counter (+ (counter) 1))
|
|
|
|
(deadline (+ (deadline) 1000))))
|
2017-09-28 16:41:17 +00:00
|
|
|
|
|
|
|
(spawn* #:name 'demo-sleep
|
|
|
|
(for [(counter (in-range 10))]
|
|
|
|
(printf "Sleeping tick ~v\n" counter)
|
|
|
|
(sleep 1.0)))
|