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

ruby-changes:17945

From: nobu <ko1@a...>
Date: Sun, 28 Nov 2010 21:46:37 +0900 (JST)
Subject: [ruby-changes:17945] Ruby:r29961 (trunk): * thread_pthread.c (thread_start_func_1): initialize native thread

nobu	2010-11-28 21:46:27 +0900 (Sun, 28 Nov 2010)

  New Revision: 29961

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

  Log:
    * thread_pthread.c (thread_start_func_1): initialize native thread
      data immediately before starting.

  Modified files:
    trunk/ChangeLog
    trunk/thread_pthread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29960)
+++ ChangeLog	(revision 29961)
@@ -1,3 +1,8 @@
+Sun Nov 28 21:46:21 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread_pthread.c (thread_start_func_1): initialize native thread
+	  data immediately before starting.
+
 Sun Nov 28 14:56:32 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* io.c (struct argf): make lineno long, and reorder members.
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 29960)
+++ thread_pthread.c	(revision 29961)
@@ -324,6 +324,8 @@
     return pthread_setspecific(ruby_native_thread_key, th) == 0;
 }
 
+static void native_thread_init(rb_thread_t *th);
+
 void
 Init_native_thread(void)
 {
@@ -331,11 +333,17 @@
 
     pthread_key_create(&ruby_native_thread_key, NULL);
     th->thread_id = pthread_self();
+    native_thread_init(th);
+    native_mutex_initialize(&signal_thread_list_lock);
+    posix_signal(SIGVTALRM, null_func);
+}
+
+static void
+native_thread_init(rb_thread_t *th)
+{
     native_cond_initialize(&th->native_thread_data.sleep_cond);
     native_cond_initialize(&th->native_thread_data.gvl_cond);
     ruby_thread_set_native(th);
-    native_mutex_initialize(&signal_thread_list_lock);
-    posix_signal(SIGVTALRM, null_func);
 }
 
 static void
@@ -519,6 +527,7 @@
 #ifndef __CYGWIN__
 	native_thread_init_stack(th);
 #endif
+	native_thread_init(th);
 	/* run */
 	thread_start_func_2(th, &stack_start, rb_ia64_bsp());
     }
@@ -679,10 +688,6 @@
 	err = pthread_create(&th->thread_id, &attr, thread_start_func_1, th);
 	thread_debug("create: %p (%d)", (void *)th, err);
 	CHECK_ERR(pthread_attr_destroy(&attr));
-
-	if (!err) {
-	    pthread_cond_init(&th->native_thread_data.sleep_cond, 0);
-	}
     }
     return err;
 }

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

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