mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Trim srfi-18 thread startup machinery
* module/srfi/srfi-18.scm (make-thread): Use just one cond/mutex pair for signalling in both directions: waiting for launch and waiting for start.
This commit is contained in:
parent
59fdf9cdcd
commit
6bf9c65419
1 changed files with 6 additions and 10 deletions
|
@ -147,17 +147,13 @@
|
||||||
;; exceptions wrapped in an uncaught-exception wrapper.
|
;; exceptions wrapped in an uncaught-exception wrapper.
|
||||||
|
|
||||||
(define* (make-thread thunk #:optional name)
|
(define* (make-thread thunk #:optional name)
|
||||||
(let ((lm (make-mutex 'launch-mutex))
|
(let ((sm (make-mutex 'start-mutex))
|
||||||
(lc (make-condition-variable 'launch-condition-variable))
|
|
||||||
(sm (make-mutex 'start-mutex))
|
|
||||||
(sc (make-condition-variable 'start-condition-variable)))
|
(sc (make-condition-variable 'start-condition-variable)))
|
||||||
(threads:lock-mutex lm)
|
(threads:lock-mutex sm)
|
||||||
(let ((t (threads:call-with-new-thread
|
(let ((t (threads:call-with-new-thread
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(threads:lock-mutex lm)
|
|
||||||
(threads:signal-condition-variable lc)
|
|
||||||
(threads:lock-mutex sm)
|
(threads:lock-mutex sm)
|
||||||
(threads:unlock-mutex lm)
|
(threads:signal-condition-variable sc)
|
||||||
(threads:wait-condition-variable sc sm)
|
(threads:wait-condition-variable sc sm)
|
||||||
(threads:unlock-mutex sm)
|
(threads:unlock-mutex sm)
|
||||||
(thunk))
|
(thunk))
|
||||||
|
@ -168,10 +164,10 @@
|
||||||
(match (cons key args)
|
(match (cons key args)
|
||||||
(('srfi-34 obj) obj)
|
(('srfi-34 obj) obj)
|
||||||
(obj obj))))))))))
|
(obj obj))))))))))
|
||||||
(hashq-set! thread-start-conds t (cons sm sc))
|
|
||||||
(when name (hashq-set! object-names t name))
|
(when name (hashq-set! object-names t name))
|
||||||
(threads:wait-condition-variable lc lm)
|
(threads:wait-condition-variable sc sm)
|
||||||
(threads:unlock-mutex lm)
|
(hashq-set! thread-start-conds t (cons sm sc))
|
||||||
|
(threads:unlock-mutex sm)
|
||||||
t)))
|
t)))
|
||||||
|
|
||||||
(define (thread-name thread)
|
(define (thread-name thread)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue