summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-01-07 20:00:03 -0500
committerDavid Thompson <dthompson2@worcester.edu>2014-01-07 20:00:03 -0500
commit9b52e9c83c56eef77037fdd7c31e8874e96d4f6a (patch)
treeae837ff395fc3abdd8d9b1c33f712333784e5e64 /2d
parent01c04ba62ac137b15ff512353bb72cd4efae5cac (diff)
Add new scheduling procedures and rename existing ones.
* 2d/agenda.scm (agenda-schedule, schedule): Rename. (agenda-schedule-interval, schedule-interval): Rename. (schedule-next, schedule-every): New procedures. * 2d/sprite.scm: Use schedule-every. * 2d/time.scm (time-every): Use schedule-interval.
Diffstat (limited to '2d')
-rw-r--r--2d/agenda.scm35
-rw-r--r--2d/sprite.scm2
-rw-r--r--2d/time.scm2
3 files changed, 25 insertions, 14 deletions
diff --git a/2d/agenda.scm b/2d/agenda.scm
index 72b672a..93dc466 100644
--- a/2d/agenda.scm
+++ b/2d/agenda.scm
@@ -28,8 +28,10 @@
#:use-module (2d coroutine)
#:export (make-agenda
with-agenda
- agenda-schedule
- agenda-schedule-interval
+ schedule
+ schedule-interval
+ schedule-next
+ schedule-every
update-agenda
clear-agenda
wait))
@@ -168,22 +170,31 @@ and enqueue CALLBACK."
(parameterize ((current-agenda agenda))
body ...))
-(define* (agenda-schedule thunk #:optional (delay 1))
- "Schedule THUNK in the current agenda to run after DELAY updates (1
-by default)."
+(define (schedule thunk delay)
+ "Schedule THUNK within the current agenda to be applied after DELAY
+ticks."
(%agenda-schedule (current-agenda) thunk delay))
-(define* (agenda-schedule-interval thunk #:optional (interval 1) (delay 1))
- "Schedule THUNK in the current agenda to run after DELAY updates and
-run every INTERVAL updates thereafter. Both DELAY and INTERVAL default
-to 1. Simply pass THUNK and nothing else to schedule THUNK to be run
-upon every update."
+(define* (schedule-interval thunk interval #:optional (delay 1))
+ "Schedule THUNK within the current agenda to be applied after DELAY
+ticks and then to be applied every INTERVAL ticks thereafter. DELAY
+is 1 by default."
(%agenda-schedule (current-agenda)
(lambda ()
(thunk)
- (agenda-schedule-interval thunk interval interval))
+ (schedule-interval thunk interval interval))
delay))
+(define (schedule-next thunk)
+ "Schedule THUNK within the current agenda to be applied upon the
+next tick."
+ (schedule thunk 1))
+
+(define (schedule-every thunk)
+ "Schedule THUNK within the current agenda to be applied upon every
+tick."
+ (schedule-interval thunk 1))
+
(define (update-agenda)
"Update the current agenda."
(%update-agenda (current-agenda)))
@@ -195,4 +206,4 @@ upon every update."
(define* (wait #:optional (delay 1))
"Yield coroutine and schdule the continuation to be run after DELAY
ticks."
- (yield (lambda (resume) (agenda-schedule resume delay))))
+ (yield (lambda (resume) (schedule resume delay))))
diff --git a/2d/sprite.scm b/2d/sprite.scm
index 445fcff..a0f13bf 100644
--- a/2d/sprite.scm
+++ b/2d/sprite.scm
@@ -302,7 +302,7 @@ currently bound."
(hash-clear! animated-sprites))
;; Update animated sprites upon every update.
-(agenda-schedule-interval update-animated-sprites!)
+(schedule-every update-animated-sprites!)
(export make-sprite
sprite?
diff --git a/2d/time.scm b/2d/time.scm
index c9c9237..f39bc0e 100644
--- a/2d/time.scm
+++ b/2d/time.scm
@@ -34,7 +34,7 @@
be a signal, in which case the stored value of the signal will be
emitted."
(let ((ticker (make-root-signal (signal-ref-maybe value))))
- (agenda-schedule-interval
+ (schedule-interval
(lambda ()
(signal-set! ticker (signal-ref-maybe value)))
ticks)