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

ruby-changes:20399

From: kosaki <ko1@a...>
Date: Fri, 8 Jul 2011 13:50:34 +0900 (JST)
Subject: [ruby-changes:20399] kosaki:r32447 (trunk): * thread.c (rb_mutex_unlock_all): folded into

kosaki	2011-07-08 13:50:25 +0900 (Fri, 08 Jul 2011)

  New Revision: 32447

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

  Log:
    * thread.c (rb_mutex_unlock_all): folded into
      rb_threadptr_unlock_all_locking_mutexes.
    * thread.c (rb_threadptr_unlock_all_locking_mutexes) ditto.

  Modified files:
    trunk/ChangeLog
    trunk/thread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 32446)
+++ ChangeLog	(revision 32447)
@@ -1,3 +1,9 @@
+Fri Jul  8 13:47:39 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* thread.c (rb_mutex_unlock_all): folded into
+	  rb_threadptr_unlock_all_locking_mutexes.
+	* thread.c (rb_threadptr_unlock_all_locking_mutexes) ditto.
+
 Fri Jul  8 13:36:02 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* thread.c (thread_unlock_all_locking_mutexes): rename to
Index: thread.c
===================================================================
--- thread.c	(revision 32446)
+++ thread.c	(revision 32447)
@@ -331,10 +331,27 @@
     struct rb_mutex_struct *next_mutex;
 } rb_mutex_t;
 
-static void rb_mutex_unlock_all(rb_mutex_t *mutex, rb_thread_t *th);
 static void rb_mutex_abandon_all(rb_mutex_t *mutexes);
+static const char* rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t volatile *th);
 
 void
+rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th)
+{
+    const char *err;
+    rb_mutex_t *mutex;
+    rb_mutex_t *mutexes = th->keeping_mutexes;
+
+    while (mutexes) {
+	mutex = mutexes;
+	/* rb_warn("mutex #<%p> remains to be locked by terminated thread",
+		mutexes); */
+	mutexes = mutex->next_mutex;
+	err = rb_mutex_unlock_th(mutex, th);
+	if (err) rb_bug("invalid keeping_mutexes: %s", err);
+    }
+}
+
+void
 rb_thread_terminate_all(void)
 {
     rb_thread_t *th = GET_THREAD(); /* main thread */
@@ -346,9 +363,7 @@
     }
 
     /* unlock all locking mutexes */
-    if (th->keeping_mutexes) {
-	rb_mutex_unlock_all(th->keeping_mutexes, GET_THREAD());
-    }
+    rb_threadptr_unlock_all_locking_mutexes(th);
 
     thread_debug("rb_thread_terminate_all (main thread: %p)\n", (void *)th);
     st_foreach(vm->living_threads, terminate_i, (st_data_t)th);
@@ -365,15 +380,6 @@
     }
 }
 
-void
-rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th)
-{
-    if (th->keeping_mutexes) {
-	rb_mutex_unlock_all(th->keeping_mutexes, th);
-	th->keeping_mutexes = NULL;
-    }
-}
-
 static void
 thread_cleanup_func_before_exec(void *th_ptr)
 {
@@ -3607,22 +3613,6 @@
 }
 
 static void
-rb_mutex_unlock_all(rb_mutex_t *mutexes, rb_thread_t *th)
-{
-    const char *err;
-    rb_mutex_t *mutex;
-
-    while (mutexes) {
-	mutex = mutexes;
-	/* rb_warn("mutex #<%p> remains to be locked by terminated thread",
-		mutexes); */
-	mutexes = mutex->next_mutex;
-	err = rb_mutex_unlock_th(mutex, th);
-	if (err) rb_bug("invalid keeping_mutexes: %s", err);
-    }
-}
-
-static void
 rb_mutex_abandon_all(rb_mutex_t *mutexes)
 {
     rb_mutex_t *mutex;

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

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