From 22a23a79d9325f8f7ba963fae706bca46de2a491 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 6 Oct 2013 08:17:04 -0400 Subject: Move wait procedure into agenda module. --- 2d/agenda.scm | 9 ++++++++- 2d/coroutine.scm | 11 ++--------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to '2d') diff --git a/2d/agenda.scm b/2d/agenda.scm index 77983b2..c336ff1 100644 --- a/2d/agenda.scm +++ b/2d/agenda.scm @@ -25,12 +25,14 @@ #:use-module (ice-9 q) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) + #:use-module (2d coroutine) #:export (make-agenda with-agenda agenda-schedule agenda-schedule-interval update-agenda - clear-agenda)) + clear-agenda + wait)) ;; This code is a modified version of the agenda implementation in ;; SICP. Thank you, SICP! @@ -192,3 +194,8 @@ upon every update." (define (clear-agenda) "Clear the current agenda." (%clear-agenda *current-agenda*)) + +(define* (wait #:optional (delay 1)) + "Yield coroutine and schdule the continuation to be run after DELAY +ticks." + (yield (lambda (resume) (agenda-schedule resume delay)))) diff --git a/2d/coroutine.scm b/2d/coroutine.scm index ba7659e..3e4d256 100644 --- a/2d/coroutine.scm +++ b/2d/coroutine.scm @@ -25,10 +25,8 @@ #:export (coroutine colambda codefine - codefine* - wait) - #:replace (yield) - #:use-module (2d agenda)) + codefine*) + #:replace (yield)) (define (coroutine thunk) "Calls a procedure that can yield a continuation." @@ -76,8 +74,3 @@ keyword arguments that is run as a coroutine." (define (yield callback) "Yield continuation to a CALLBACK procedure." (abort-to-prompt 'coroutine-prompt callback)) - -(define* (wait #:optional (delay 1)) - "Yield coroutine and schdule the continuation to be run after DELAY -ticks." - (yield (lambda (resume) (agenda-schedule resume delay)))) -- cgit v1.2.3