From: Christopher Allan Webber Date: Tue, 17 Nov 2015 22:53:25 +0000 (-0600) Subject: agenda now actually runs (but doesn't do anything useful...) X-Git-Tag: v0.1.0~176 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=8ef593dc9802e11f3222ab81e021e8807fd8bdb9;p=8sync.git agenda now actually runs (but doesn't do anything useful...) --- diff --git a/loopy.scm b/loopy.scm index 3db157d..0f6edc5 100644 --- a/loopy.scm +++ b/loopy.scm @@ -7,18 +7,20 @@ ;; replace this (define-immutable-record-type - (make-agenda queue) + (make-agenda-intern queue) agenda? (queue agenda-queue)) -(define %current-agenda - (make-parameter (make-agenda (make-q)))) +(define* (make-agenda #:key (queue (make-q))) + (make-agenda-intern queue)) + +(define %current-agenda (make-parameter #f)) (define* (start-agenda agenda #:optional stop-condition) (let loop ((agenda agenda)) (let ((new-agenda - (agenda-run-once agenda))) - (%current-agenda new-agenda) + (parameterize ((%current-agenda agenda)) + (agenda-run-once agenda)))) (if (and stop-condition (stop-condition)) 'done (loop new-agenda))))) @@ -38,11 +40,11 @@ based on the results" (match proc-result ((? procedure? new-proc) (enqueue new-proc)) - (((? procedure? new-procs) ..) + (((? procedure? new-procs) ...) (for-each (lambda (new-proc) (enqueue new-proc)) - new-procs))) - ;; TODO: Selecting on ports would happen here? - ;; Return new agenda, with next queue set - (set-field agenda (agenda-queue) next-queue))))) + new-procs))))) + ;; TODO: Selecting on ports would happen here? + ;; Return new agenda, with next queue set + (set-field agenda (agenda-queue) next-queue)))