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

ruby-changes:25827

From: kosaki <ko1@a...>
Date: Tue, 27 Nov 2012 11:00:54 +0900 (JST)
Subject: [ruby-changes:25827] kosaki:r37884 (trunk): * thread.c (thread_join): raises ThreadError if target therad

kosaki	2012-11-27 11:00:19 +0900 (Tue, 27 Nov 2012)

  New Revision: 37884

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

  Log:
    * thread.c (thread_join): raises ThreadError if target therad
      is a main thread.
    * test/ruby/test_thread.rb (test_thread_join_main_thread):
      test for the above.
    * NEWS: news for the above.

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/test/ruby/test_thread.rb
    trunk/thread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37883)
+++ ChangeLog	(revision 37884)
@@ -1,3 +1,11 @@
+Tue Nov 27 09:29:11 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* thread.c (thread_join): raises ThreadError if target therad
+	  is a main thread.
+	* test/ruby/test_thread.rb (test_thread_join_main_thread):
+	  test for the above.
+	* NEWS: news for the above.
+
 Tue Nov 27 09:24:47 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* thread.c (thread_join): raises ThreadError if target thread
Index: thread.c
===================================================================
--- thread.c	(revision 37883)
+++ thread.c	(revision 37884)
@@ -739,6 +739,9 @@
     if (th == target_th) {
 	rb_raise(rb_eThreadError, "Target thread must not be current thread");
     }
+    if (GET_VM()->main_thread == target_th) {
+	rb_raise(rb_eThreadError, "Target thread must not be main thread");
+    }
 
     arg.target = target_th;
     arg.waiting = th;
Index: NEWS
===================================================================
--- NEWS	(revision 37883)
+++ NEWS	(revision 37884)
@@ -160,7 +160,7 @@
     * incompatible changes:
       * Thread#join no longer allows to be used from trap handler. Now it raises
         ThreadError.
-      * Thread#join raises ThreadError if target therad is a current thread.
+      * Thread#join raises ThreadError if target therad is a current or main thread. 
 
   * Time
     * change return value:
Index: test/ruby/test_thread.rb
===================================================================
--- test/ruby/test_thread.rb	(revision 37883)
+++ test/ruby/test_thread.rb	(revision 37884)
@@ -881,4 +881,12 @@
       Thread.current.join
     end
   end
+
+  def test_thread_join_main_thread
+    assert_raises(ThreadError) do
+      Thread.new(Thread.current) {|t|
+        t.join
+      }.join
+    end
+  end
 end

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

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