syndicate-rkt/syndicate-examples/until-demo.rkt

25 lines
1.0 KiB
Racket

#lang syndicate
;;; SPDX-License-Identifier: LGPL-3.0-or-later
;;; SPDX-FileCopyrightText: Copyright © 2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
(require syndicate/drivers/racket-event)
(require racket/port)
(module+ main
(actor-system/dataspace (ds)
(spawn-racket-event-driver ds)
(spawn
(log-info "Enter a line ~v ~v" this-turn this-facet)
(until ds (message (RacketEvent (read-line-evt (current-input-port)) _))
(on-start (log-info "Waiting"))
(on-stop (log-info "Resuming")))
(log-info "Enter another line ~v ~v" this-turn this-facet)
(until ds (message (RacketEvent (read-line-evt (current-input-port)) _))
(on-start (log-info "Waiting"))
(on-stop (log-info "Resuming")))
(log-info "Enter a third line ~v ~v" this-turn this-facet)
(until ds (message (RacketEvent (read-line-evt (current-input-port)) _))
(on-start (log-info "Waiting"))
(on-stop (log-info "Resuming")))
(log-info "Well done. ~v ~v" this-turn this-facet))))