Racket implementation of Dataspaces and Syndicate.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
897 B

;;; SPDX-License-Identifier: LGPL-3.0-or-later
;;; SPDX-FileCopyrightText: Copyright © 2010-2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
#lang syndicate
(require/activate syndicate/drivers/timer)
(spawn #:name 'plain-timer-demo
(field [count 0])
(on-start (send! (set-timer 'main-timer 0 'relative)))
(on (message (timer-expired 'main-timer $now))
(log-info "main-timer expired at ~a" now)
(count (+ (count) 1))
(when (< (count) 5)
(send! (set-timer 'main-timer 500 'relative)))))
(spawn #:name 'later-than-demo
(field [deadline (current-inexact-milliseconds)]
[count 0])
(on (asserted (later-than (deadline)))
(log-info "later-than ticked for deadline ~a" (deadline))
(count (+ (count) 1))
(when (< (count) 5)
(deadline (+ (deadline) 500)))))