summaryrefslogtreecommitdiff
path: root/module/srfi/srfi-18.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2016-10-30 20:38:18 +0100
committerAndy Wingo <wingo@pobox.com>2016-10-30 20:43:07 +0100
commit501c0e67b1977136a6e7677de007e5301f55adda (patch)
treebfbfdb4bb8e8224815c99d8c17eb9bf10db9fb69 /module/srfi/srfi-18.scm
parente5399d3e7ca5de4e1981a9a9ddf136bd9d743c54 (diff)
downloadguile-501c0e67b1977136a6e7677de007e5301f55adda.tar.gz
srfi-18: Improve style.
* module/srfi/srfi-18.scm (raise): Rely on SRFI-34 to #:replace raise. (make-thread): Use lambda* and when.
Diffstat (limited to 'module/srfi/srfi-18.scm')
-rw-r--r--module/srfi/srfi-18.scm18
1 files changed, 7 insertions, 11 deletions
diff --git a/module/srfi/srfi-18.scm b/module/srfi/srfi-18.scm
index e2d904770..756508c88 100644
--- a/module/srfi/srfi-18.scm
+++ b/module/srfi/srfi-18.scm
@@ -70,7 +70,6 @@
current-exception-handler
with-exception-handler
- raise
join-timeout-exception?
abandoned-mutex-exception?
terminated-thread-exception?
@@ -79,12 +78,12 @@
#:re-export ((threads:condition-variable? . condition-variable?)
(threads:current-thread . current-thread)
(threads:thread? . thread?)
- (threads:mutex? . mutex?))
+ (threads:mutex? . mutex?)
+ raise)
#:replace (current-time
make-thread
make-mutex
- make-condition-variable
- raise))
+ make-condition-variable))
(unless (provided? 'threads)
(error "SRFI-18 requires Guile with threads support"))
@@ -109,7 +108,6 @@
;; EXCEPTIONS
-(define raise (@ (srfi srfi-34) raise))
(define (initial-handler obj)
(srfi-18-exception-preserver (cons uncaught-exception obj)))
@@ -180,11 +178,9 @@
(threads:wait-condition-variable scond smutex)
(threads:unlock-mutex smutex)
(with-exception-handler initial-handler
- thunk)))))
- (lambda (thunk . name)
- (let ((n (and (pair? name) (car name)))
-
- (lm (make-mutex 'launch-mutex))
+ thunk)))))
+ (lambda* (thunk #:optional name)
+ (let ((lm (make-mutex 'launch-mutex))
(lc (make-condition-variable 'launch-condition-variable))
(sm (make-mutex 'start-mutex))
(sc (make-condition-variable 'start-condition-variable)))
@@ -194,7 +190,7 @@
(make-cond-wrapper thunk lc lm sc sm)
srfi-18-exception-handler)))
(hashq-set! thread-start-conds t (cons sm sc))
- (and n (hashq-set! object-names t n))
+ (when name (hashq-set! object-names t name))
(threads:wait-condition-variable lc lm)
(threads:unlock-mutex lm)
t)))))