mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 06:39:17 +02:00
16 lines
459 B
Scheme
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!)))
|
|
|