If we are re-awakened waiting on a thread-join! but without timing out,

try to join again to make sure it's really dead.
This commit is contained in:
Alex Shinn 2012-10-13 23:51:55 +09:00
parent b5046925f7
commit 3d161d4d2f

View file

@ -22,18 +22,19 @@
(define (thread-join! thread . o) (define (thread-join! thread . o)
(let ((timeout (and (pair? o) (car o)))) (let ((timeout (and (pair? o) (car o))))
(cond (let lp ()
((%thread-join! thread (timeout->seconds timeout))
(thread-result thread))
(else
(thread-yield!)
(cond (cond
((and timeout (thread-timeout?)) ((%thread-join! thread (timeout->seconds timeout))
(if (and (pair? o) (pair? (cdr o))) (thread-result thread))
(cadr o)
(error "timed out waiting for thread" thread)))
(else (else
(thread-result thread))))))) (thread-yield!)
(cond
((and timeout (thread-timeout?))
(if (and (pair? o) (pair? (cdr o)))
(cadr o)
(error "timed out waiting for thread" thread)))
(else
(lp))))))))
(define (thread-terminate! thread) (define (thread-terminate! thread)
(if (%thread-terminate! thread) ;; need to yield if terminating ourself (if (%thread-terminate! thread) ;; need to yield if terminating ourself