[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 13/17: Trim srfi-18 thread startup machinery

From: Andy Wingo
Subject: [Guile-commits] 13/17: Trim srfi-18 thread startup machinery
Date: Mon, 31 Oct 2016 21:39:37 +0000 (UTC)

wingo pushed a commit to branch master
in repository guile.

commit 6bf9c6541937469f32228008634307824a902ecb
Author: Andy Wingo <address@hidden>
Date:   Mon Oct 31 21:42:47 2016 +0100

    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
 module/srfi/srfi-18.scm |   16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/module/srfi/srfi-18.scm b/module/srfi/srfi-18.scm
index aa2b2b2..fe5e764 100644
--- a/module/srfi/srfi-18.scm
+++ b/module/srfi/srfi-18.scm
@@ -147,17 +147,13 @@
 ;; exceptions wrapped in an uncaught-exception wrapper. 
 (define* (make-thread thunk #:optional name)
-  (let ((lm (make-mutex 'launch-mutex))
-        (lc (make-condition-variable 'launch-condition-variable))
-        (sm (make-mutex 'start-mutex))
+  (let ((sm (make-mutex 'start-mutex))
         (sc (make-condition-variable 'start-condition-variable)))
-    (threads:lock-mutex lm)
+    (threads:lock-mutex sm)
     (let ((t (threads:call-with-new-thread
               (lambda ()
-                (threads:lock-mutex lm)
-                (threads:signal-condition-variable lc)
                 (threads:lock-mutex sm)
-                (threads:unlock-mutex lm)
+                (threads:signal-condition-variable sc)
                 (threads:wait-condition-variable sc sm)
                 (threads:unlock-mutex sm)
@@ -168,10 +164,10 @@
                                (match (cons key args)
                                  (('srfi-34 obj) obj)
                                  (obj obj))))))))))
-      (hashq-set! thread-start-conds t (cons sm sc))
       (when name (hashq-set! object-names t name))
-      (threads:wait-condition-variable lc lm)
-      (threads:unlock-mutex lm)
+      (threads:wait-condition-variable sc sm)
+      (hashq-set! thread-start-conds t (cons sm sc))
+      (threads:unlock-mutex sm)
 (define (thread-name thread)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]