chibi-scheme/lib/srfi/18/interface.scm
2010-07-04 07:43:41 +00:00

16 lines
459 B
Scheme

(define (thread-join! thread . o)
(let ((timeout (if (pair? o) (car o) #f)))
(cond
((%thread-join! thread timeout))
(else
(thread-yield!)
(if (thread-timeout?)
(if (and (pair? o) (pair? (cdr o)))
(cadr o)
(error "timed out waiting for thread" thread)))))))
(define (thread-terminate! thread)
(if (%thread-terminate! thread) ;; need to yield if terminating ourself
(thread-yield!)))