mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 13:49:17 +02:00
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:
parent
b5046925f7
commit
3d161d4d2f
1 changed files with 11 additions and 10 deletions
|
@ -22,18 +22,19 @@
|
|||
|
||||
(define (thread-join! thread . o)
|
||||
(let ((timeout (and (pair? o) (car o))))
|
||||
(cond
|
||||
((%thread-join! thread (timeout->seconds timeout))
|
||||
(thread-result thread))
|
||||
(else
|
||||
(thread-yield!)
|
||||
(let lp ()
|
||||
(cond
|
||||
((and timeout (thread-timeout?))
|
||||
(if (and (pair? o) (pair? (cdr o)))
|
||||
(cadr o)
|
||||
(error "timed out waiting for thread" thread)))
|
||||
((%thread-join! thread (timeout->seconds timeout))
|
||||
(thread-result thread))
|
||||
(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)
|
||||
(if (%thread-terminate! thread) ;; need to yield if terminating ourself
|
||||
|
|
Loading…
Add table
Reference in a new issue