[前][次][番号順一覧][スレッド一覧]

ruby-changes:4440

From: ko1@a...
Date: Wed, 9 Apr 2008 14:43:44 +0900 (JST)
Subject: [ruby-changes:4440] nobu - Ruby:r15931 (trunk): * thread.c (lock_func): optimized and checks for interrupt_flag.

nobu	2008-04-09 14:43:29 +0900 (Wed, 09 Apr 2008)

  New Revision: 15931

  Modified files:
    trunk/ChangeLog
    trunk/thread.c

  Log:
    * thread.c (lock_func): optimized and checks for interrupt_flag.
      based on a patch from Sylvain Joyeux in [ruby-Patches-19361] and
      [ruby-Patches-19362].


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15931&r2=15930&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/thread.c?r1=15931&r2=15930&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15930)
+++ ChangeLog	(revision 15931)
@@ -1,3 +1,9 @@
+Wed Apr  9 14:43:26 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread.c (lock_func): optimized and checks for interrupt_flag.
+	  based on a patch from Sylvain Joyeux in [ruby-Patches-19361] and
+	  [ruby-Patches-19362].
+
 Wed Apr  9 12:12:01 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* test/ruby/test_thread.rb: new tests from Sylvain Joyeux in
@@ -3,9 +9,6 @@
 	  [ruby-Patches-19361].
 
-Tue Apr  8 21:38:55 2008  Nobuyoshi Nakada  <nobu@r...>
+Tue Apr  8 21:36:40 2008  Nobuyoshi Nakada  <nobu@r...>
 
-	* thread.c (lock_func): optimized.  based on a patch from Sylvain
-	  Joyeux in [ruby-Patches-19362].
-
 	* thread.c (rb_mutex_sleep): ensures to re-acquire at waking up.
 	  [ruby-Patches-19361]
Index: thread.c
===================================================================
--- thread.c	(revision 15930)
+++ thread.c	(revision 15931)
@@ -2320,30 +2320,19 @@
 static VALUE
 lock_func(rb_thread_t *th, mutex_t *mutex)
 {
-    int locked = 0;
+    native_mutex_lock(&mutex->lock);
+    while (mutex->th) {
+	mutex->cond_waiting++;
+	native_cond_wait(&mutex->cond, &mutex->lock);
 
-    while (locked == 0) {
-	native_mutex_lock(&mutex->lock);
-	{
-	    if (mutex->th == 0) {
-		mutex->th = th;
-		locked = 1;
-	    }
-	    else {
-		mutex->cond_waiting++;
-		native_cond_wait(&mutex->cond, &mutex->lock);
-
-		if (th->interrupt_flag) {
-		    locked = 1;
-		}
-		else if (mutex->th == 0) {
-		    mutex->th = th;
-		    locked = 1;
-		}
-	    }
+	if (th->interrupt_flag) {
+	    native_mutex_unlock(&mutex->lock);
+	    RUBY_VM_CHECK_INTS();
+	    native_mutex_lock(&mutex->lock);
 	}
-	native_mutex_unlock(&mutex->lock);
     }
+    mutex->th = th;
+    native_mutex_unlock(&mutex->lock);
     return Qnil;
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]