mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-29 08:20:20 +02:00
Refactor thread-join! to use optional args.
* module/srfi/srfi-18.scm (thread-join!): Use optional args. Also don't treat false return values from threads as meaning anything.
This commit is contained in:
parent
8e305ee045
commit
59fdf9cdcd
1 changed files with 14 additions and 7 deletions
|
@ -254,15 +254,22 @@
|
||||||
(threads:cancel-thread thread)
|
(threads:cancel-thread thread)
|
||||||
*unspecified*))
|
*unspecified*))
|
||||||
|
|
||||||
(define (thread-join! thread . args)
|
;; A unique value.
|
||||||
|
(define %sentinel (list 1))
|
||||||
|
(define* (thread-join! thread #:optional (timeout %sentinel)
|
||||||
|
(timeoutval %sentinel))
|
||||||
(with-exception-handlers-here
|
(with-exception-handlers-here
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let ((v (apply threads:join-thread thread args))
|
(let ((v (if (eq? timeout %sentinel)
|
||||||
(e (thread->exception thread)))
|
(threads:join-thread thread)
|
||||||
(if (and (= (length args) 1) (not v))
|
(threads:join-thread thread timeout %sentinel))))
|
||||||
(srfi-34:raise (condition (&join-timeout-exception))))
|
(cond
|
||||||
(if e (srfi-34:raise e))
|
((eq? v %sentinel)
|
||||||
v))))
|
(if (eq? timeoutval %sentinel)
|
||||||
|
(srfi-34:raise (condition (&join-timeout-exception)))
|
||||||
|
timeoutval))
|
||||||
|
((thread->exception thread) => srfi-34:raise)
|
||||||
|
(else v))))))
|
||||||
|
|
||||||
;; MUTEXES
|
;; MUTEXES
|
||||||
;; These functions are all pass-thrus to the existing Guile implementations.
|
;; These functions are all pass-thrus to the existing Guile implementations.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue