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

ruby-changes:25897

From: kosaki <ko1@a...>
Date: Thu, 29 Nov 2012 07:03:25 +0900 (JST)
Subject: [ruby-changes:25897] kosaki:r37955 (trunk): * thread.c (thread_start_func_2): remove unused code.

kosaki	2012-11-29 06:55:14 +0900 (Thu, 29 Nov 2012)

  New Revision: 37955

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

  Log:
    * thread.c (thread_start_func_2): remove unused code.
      this function never be used for main thread.

  Modified files:
    trunk/ChangeLog
    trunk/thread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37954)
+++ ChangeLog	(revision 37955)
@@ -1,3 +1,8 @@
+Thu Nov 29 06:37:08 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* thread.c (thread_start_func_2): remove unused code.
+	  this function never be used for main thread.
+
 Thu Nov 29 06:27:55 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* thread.c (thread_start_func_2): remove unused code.
Index: thread.c
===================================================================
--- thread.c	(revision 37954)
+++ thread.c	(revision 37955)
@@ -454,6 +454,9 @@
     rb_register_sigaltstack(th);
 # endif
 
+    if (th == th->vm->main_thread)
+	rb_bug("thread_start_func_2 must not used for main thread");
+
     ruby_thread_set_native(th);
 
     th->machine_stack_start = stack_start;
@@ -502,11 +505,9 @@
 	thread_debug("thread end: %p\n", (void *)th);
 
 	main_th = th->vm->main_thread;
-	if (th != main_th) {
-	    if (RB_TYPE_P(errinfo, T_OBJECT)) {
-		/* treat with normal error object */
-		rb_threadptr_raise(main_th, 1, &errinfo);
-	    }
+	if (RB_TYPE_P(errinfo, T_OBJECT)) {
+	    /* treat with normal error object */
+	    rb_threadptr_raise(main_th, 1, &errinfo);
 	}
 	TH_POP_TAG();
 
@@ -517,17 +518,15 @@
 	}
 
 	/* delete self other than main thread from living_threads */
-	if (th != main_th) {
-	    st_delete_wrap(th->vm->living_threads, th->self);
-	    if (rb_thread_alone()) {
-		rb_threadptr_interrupt(main_th);
-	    }
+	st_delete_wrap(th->vm->living_threads, th->self);
+	if (rb_thread_alone()) {
+	    /* I'm last thread. wake up main thread from rb_thread_terminate_all */
+	    rb_threadptr_interrupt(main_th);
 	}
 
 	/* wake up joining threads */
 	join_list = th->join_list;
 	while (join_list) {
-	    if (join_list->th == main_th) errinfo = Qnil;
 	    rb_threadptr_interrupt(join_list->th);
 	    switch (join_list->th->status) {
 	      case THREAD_STOPPED: case THREAD_STOPPED_FOREVER:
@@ -538,20 +537,15 @@
 	}
 
 	rb_threadptr_unlock_all_locking_mutexes(th);
-	if (th != main_th) rb_check_deadlock(th->vm);
+	rb_check_deadlock(th->vm);
 
 	if (!th->root_fiber) {
 	    rb_thread_recycle_stack_release(th->stack);
 	    th->stack = 0;
 	}
     }
-    if (th->vm->main_thread == th) {
-	ruby_cleanup(state);
-    }
-    else {
-	thread_cleanup_func(th, FALSE);
-	gvl_release(th->vm);
-    }
+    thread_cleanup_func(th, FALSE);
+    gvl_release(th->vm);
 
     return 0;
 }

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

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