svn: r5506

original commit: bfc693c06348d44012ba59b289d14ae1ca84ea2b
This commit is contained in:
Matthew Flatt 2007-01-30 06:34:05 +00:00
parent f742e5e985
commit 842e4b257e
2 changed files with 11 additions and 8 deletions

View File

@ -517,7 +517,8 @@
(begin
;; This means that we let too many bytes
;; get written while a special was pending.
;; Too bad...
;; (The limit is disabled when a special
;; is in the pipe.)
(set-car! more (subbytes (car more) wrote))
;; By peeking, make room for more:
(peek-byte r (sub1 (min (pipe-content-length w)
@ -589,7 +590,6 @@
(list 'reply (cadr req) (caddr req) v))])
(case (car req)
[(read)
(printf "read~n")
(reply (read-one (cadddr req)))]
[(close)
(reply (close-it))]
@ -640,7 +640,8 @@
(min (- end start)
(max 0
(- limit (pipe-content-length w)))))])
(if (zero? len)
(if (and (zero? len)
(null? more))
(handle-evt w (lambda (x) (loop reqs)))
(handle-evt (channel-put-evt (cadr req) len)
(lambda (x)
@ -673,7 +674,7 @@
(call-with-semaphore
lock-semaphore
(lambda ()
(unless via-manager?
(unless mgr-th
(set! mgr-th (thread serve)))
(set! via-manager? #t)
(thread-resume mgr-th (current-thread))

View File

@ -56,6 +56,8 @@
;; coroutines ----------------------------------------
(define MAX-RUN-TIME 100) ; in msecs
(define cntr 0)
(define w (coroutine (lambda (enable-stop)
(let loop ((i 0))
@ -65,7 +67,7 @@
(loop (add1 i))))))
(test #t coroutine? w)
(test #f coroutine-result w)
(test #f coroutine-run 0.1 w)
(test #f coroutine-run MAX-RUN-TIME w)
(test #t positive? cntr)
(test (void) coroutine-kill w)
(test #t coroutine-run 100 w)
@ -79,13 +81,13 @@
(set! cntr i)
(enable-stop #t)
(loop (sub1 i))))))))
(test #t coroutine-run 0.1 w2)
(test #t coroutine-run MAX-RUN-TIME w2)
(test 13 coroutine-result w2)
(test #t coroutine-run 100 w2)
(define w3 (coroutine (lambda (enable-stop)
(raise 14))))
(err/rt-test (coroutine-run 0.1 w3) (lambda (x) (eq? x 14)))
(err/rt-test (coroutine-run MAX-RUN-TIME w3) (lambda (x) (eq? x 14)))
(test #f coroutine-result w3)
(test #t coroutine-run 100 w3)
@ -93,5 +95,5 @@
(enable-stop #f)
(raise 15))))
(test #f coroutine-result w4)
(err/rt-test (coroutine-run 0.1 w4) (lambda (x) (eq? x 15)))
(err/rt-test (coroutine-run MAX-RUN-TIME w4) (lambda (x) (eq? x 15)))
(test #t coroutine-run 100 w4)