fix `delay/thread' error when promise-running thread terminates

This commit is contained in:
Matthew Flatt 2012-08-29 09:21:12 -06:00
parent 6039e35afd
commit b4fea2ff36
2 changed files with 11 additions and 4 deletions

View File

@ -98,9 +98,13 @@
(lambda (p) (lambda (p)
(reify-result (let ([v (pref p)]) (reify-result (let ([v (pref p)])
(if (running-thread? v) (if (running-thread? v)
(begin (thread-wait (running-thread-thread v)) (let ([t (running-thread-thread v)])
(pref p)) (thread-wait t)
v)))) (let ([v (pref p)])
(if (running-thread? v)
(error 'force "promise's thread terminated without result or exception\n promise: ~e" p)
v)))
v))))
#:property prop:evt #:property prop:evt
(lambda (p) (lambda (p)
(let ([v (pref p)]) (let ([v (pref p)])

View File

@ -111,7 +111,10 @@ group} specified by @racket[thread-group-expr], which defaults to
appear at most once. appear at most once.
Exceptions raised by the @racket[body]s are caught as usual and raised Exceptions raised by the @racket[body]s are caught as usual and raised
only when the promise is @racket[force]d.} only when the promise is @racket[force]d. Unlike @racket[delay/sync],
if the thread running @racket[body] terminates without producing a result
or exception, @racket[force] of the promise raises an exception (instead
of blocking).}
@defform/subs[(delay/idle body/option ...+) @defform/subs[(delay/idle body/option ...+)
([body/option body ([body/option body