summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-11-30 14:21:41 -0500
committerDavid Thompson <dthompson2@worcester.edu>2014-11-30 14:21:41 -0500
commit23d628e4d6692f4e9636e1eb380d80dfda2acad9 (patch)
treecbb31ec44888efccc960ac9e94fedc70114ed794
parente87d73810cb0a47cd31f9d0f3a65a4a39435883c (diff)
signal: Change parameter name in signal-sample.
* sly/signal.scm (signal-sample): Change 'delay' to 'step'.
-rw-r--r--sly/signal.scm24
1 files changed, 11 insertions, 13 deletions
diff --git a/sly/signal.scm b/sly/signal.scm
index bf69438..b1209e8 100644
--- a/sly/signal.scm
+++ b/sly/signal.scm
@@ -317,14 +317,14 @@ time that the value of SIGNAL was received and whose cdr is the value
of SIGNAL."
(signal-map (cut cons (agenda-time) <>) signal))
-(define (signal-sample delay signal)
(define (signal-time signal)
"Create a new signal whose value is the time that the latest value
of SIGNAL was received."
(signal-map (lambda _ (agenda-time)) signal))
+(define (signal-sample step signal)
"Create a new signal that emits the value contained within SIGNAL
-every DELAY ticks of the current agenda."
+every STEP ticks of the current agenda."
;; To prevent memory leaks, the new signal is stored within a weak
;; value hash table and never bound to a variable within the main
;; body of the procedure. When this signal is GC'd, the sampling
@@ -334,25 +334,19 @@ every DELAY ticks of the current agenda."
(hash-ref container 'signal))
(define (sample!)
- (let ((sampler (get)))
- (if sampler
- (begin
- (signal-set! sampler (signal-ref signal))
- #t)
- #f)))
+ (and=> (get)
+ (lambda (sampler)
+ (signal-set! sampler (signal-ref signal))
+ #t)))
(hash-set! container 'signal (make-signal (signal-ref signal)))
(coroutine
(let loop ()
- (wait delay)
+ (wait step)
(when (sample!)
(loop))))
(get)))
-(define (signal-delay delay signal)
- "Create a new signal that delays propagation of SIGNAL by DELAY
-ticks of the current agenda."
- (make-boxed-signal (signal-ref signal)
(define (signal-every step)
"Create a new signal that emits STEP every STEP ticks."
(signal-sample step (make-signal step)))
@@ -364,6 +358,10 @@ received from SIGNAL in STEP increments."
(- (agenda-time) time))
(signal-sample step (signal-time signal))))
+(define (signal-delay delay signal)
+ "Create a new signal that delays propagation of SIGNAL by DELAY
+ticks of the current agenda."
+ (make-boxed-signal (signal-ref signal)
(lambda (self value)
(schedule
(lambda ()