1 (use-modules (srfi srfi-9)
6 ;; @@: Using immutable agendas here, so wouldn't it make sense to
9 (define-immutable-record-type <agenda>
14 (define %current-agenda
15 (make-parameter (make-agenda (make-q))))
17 (define* (start-agenda agenda #:optional stop-condition)
18 (let loop ((agenda agenda))
20 (agenda-run-once agenda)))
21 (%current-agenda new-agenda)
22 (if (and stop-condition (stop-condition))
26 (define (agenda-run-once agenda)
27 "Run once through the agenda, and produce a new agenda
29 (let ((queue (agenda-queue agenda))
30 (next-queue (make-q)))
31 (while (not (q-empty? queue))
32 (let* ((proc (q-pop! queue))
36 (enq! next-queue new-proc))))
37 ;; @@: We might support delay-wrapped procedures here
39 ((? procedure? new-proc)
41 (((? procedure? new-procs) ..)
46 ;; TODO: Selecting on ports would happen here?
47 ;; Return new agenda, with next queue set
48 (set-field agenda (agenda-queue) next-queue)))))