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

ruby-changes:8048

From: nobu <ko1@a...>
Date: Fri, 26 Sep 2008 17:02:26 +0900 (JST)
Subject: [ruby-changes:8048] Ruby:r19573 (trunk): * thread.c (thlist_signal): clears the woken thread if nothing woke.

nobu	2008-09-26 17:02:07 +0900 (Fri, 26 Sep 2008)

  New Revision: 19573

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19573

  Log:
    * thread.c (thlist_signal): clears the woken thread if nothing woke.
    
    * thread.c (rb_barrier_wait): achieves the lock if no thread was
      waiting yet.

  Modified files:
    trunk/ChangeLog
    trunk/thread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 19572)
+++ ChangeLog	(revision 19573)
@@ -1,3 +1,10 @@
+Fri Sep 26 17:02:04 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread.c (thlist_signal): clears the woken thread if nothing woke.
+
+	* thread.c (rb_barrier_wait): achieves the lock if no thread was
+	  waiting yet.
+
 Fri Sep 26 12:04:07 2008  Yukihiro Matsumoto  <matz@r...>
 
 	* ext/curses/curses.c: should include <ruby/io.h>.
Index: thread.c
===================================================================
--- thread.c	(revision 19572)
+++ thread.c	(revision 19573)
@@ -3076,6 +3076,7 @@
 	    if (++woken >= maxth && maxth) break;
 	}
     }
+    if (!woken && woken_thread) *woken_thread = 0;
     return woken;
 }
 
@@ -3128,23 +3129,25 @@
 {
     rb_barrier_t *barrier;
     rb_thread_list_t *q;
+    rb_thread_t *th = GET_THREAD();
 
     Data_Get_Struct(self, rb_barrier_t, barrier);
     if (!barrier->owner || barrier->owner->status == THREAD_KILLED) {
 	barrier->owner = 0;
 	if (thlist_signal(&barrier->waiting, 1, &barrier->owner)) return Qfalse;
+	barrier->owner = th;
 	return Qtrue;
     }
-    else if (barrier->owner == GET_THREAD()) {
+    else if (barrier->owner == th) {
 	return Qfalse;
     }
     else {
 	*barrier->tail = q = ALLOC(rb_thread_list_t);
-	q->th = GET_THREAD();
+	q->th = th;
 	q->next = 0;
 	barrier->tail = &q->next;
 	rb_thread_sleep_forever();
-	return barrier->owner == GET_THREAD() ? Qtrue : Qfalse;
+	return barrier->owner == th ? Qtrue : Qfalse;
     }
 }
 

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

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