extend `sync/timeout' to allow a tail-position fail thunk for polling
original commit: 2b4f1a69085fe9b9c41b1342bcbffd6bcafc88eb
This commit is contained in:
parent
83ad612c98
commit
77b082f08f
|
@ -399,20 +399,22 @@
|
||||||
[(and (eq? evt 'wait)
|
[(and (eq? evt 'wait)
|
||||||
(not handler?))
|
(not handler?))
|
||||||
#t]
|
#t]
|
||||||
;; `yield' is supposed to return immediately if the
|
|
||||||
;; event is already ready:
|
|
||||||
[(and (evt? evt) (sync/timeout 0 (wrap-evt evt (lambda (v) (list v)))))
|
|
||||||
=> (lambda (v) (car v))]
|
|
||||||
[handler?
|
|
||||||
(sync (if (eq? evt 'wait)
|
|
||||||
(wrap-evt e (lambda (_) #t))
|
|
||||||
evt)
|
|
||||||
(handle-evt ((eventspace-queue-proc e))
|
|
||||||
(lambda (v)
|
|
||||||
(when v (handle-event v))
|
|
||||||
(yield evt))))]
|
|
||||||
[else
|
[else
|
||||||
(sync evt)]))]))
|
(define (wait-now)
|
||||||
|
(if handler?
|
||||||
|
(sync (if (eq? evt 'wait)
|
||||||
|
(wrap-evt e (lambda (_) #t))
|
||||||
|
evt)
|
||||||
|
(handle-evt ((eventspace-queue-proc e))
|
||||||
|
(lambda (v)
|
||||||
|
(when v (handle-event v))
|
||||||
|
(yield evt))))
|
||||||
|
(sync evt)))
|
||||||
|
(if (evt? evt)
|
||||||
|
;; `yield' is supposed to return immediately if the
|
||||||
|
;; event is already ready:
|
||||||
|
(sync/timeout wait-now evt)
|
||||||
|
(wait-now))]))]))
|
||||||
|
|
||||||
(define yield-refresh
|
(define yield-refresh
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user