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

ruby-changes:24441

From: naruse <ko1@a...>
Date: Mon, 23 Jul 2012 00:04:26 +0900 (JST)
Subject: [ruby-changes:24441] naruse:r36492 (trunk): * thread.c (rb_threadptr_execute_interrupts_common): increase

naruse	2012-07-23 00:04:11 +0900 (Mon, 23 Jul 2012)

  New Revision: 36492

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

  Log:
    * thread.c (rb_threadptr_execute_interrupts_common): increase
      running_time_us on THREAD_TO_KILL like on THREAD_RUNNABLE.
      This cause not to siwtch from a thread which is to be killed
      on FreeBSD and Mac OS X. see also the test.
      This issue maybe exist for long time but happens after r36430.

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36491)
+++ ChangeLog	(revision 36492)
@@ -1,3 +1,11 @@
+Sun Jul 22 23:58:48 2012  NARUSE, Yui  <naruse@r...>
+
+	* thread.c (rb_threadptr_execute_interrupts_common): increase
+	  running_time_us on THREAD_TO_KILL like on THREAD_RUNNABLE.
+	  This cause not to siwtch from a thread which is to be killed
+	  on FreeBSD and Mac OS X. see also the test.
+	  This issue maybe exist for long time but happens after r36430.
+
 Sat Jul 21 06:21:45 2012  NARUSE, Yui  <naruse@r...>
 
 	* lib/net/http.rb: fixes for r36476. [Feature #6546]
Index: thread.c
===================================================================
--- thread.c	(revision 36491)
+++ thread.c	(revision 36492)
@@ -1742,7 +1742,7 @@
 	    else
 		limits_us >>= -th->priority;
 
-	    if (status == THREAD_RUNNABLE)
+	    if (status == THREAD_RUNNABLE || status == THREAD_TO_KILL)
 		th->running_time_us += TIME_QUANTUM_USEC;
 
 	    EXEC_EVENT_HOOK(th, RUBY_EVENT_SWITCH, th->cfp->self, 0, 0);
Index: test/ruby/test_thread.rb
===================================================================
--- test/ruby/test_thread.rb	(revision 36491)
+++ test/ruby/test_thread.rb	(revision 36492)
@@ -774,4 +774,22 @@
     end
     assert_in_delta(t1 - t0, 1, 1)
   end
+
+  def test_thread_timer_and_ensure
+    exit = false
+    t = Thread.new do
+      begin
+        sleep
+      ensure
+        1 until exit # Ruby 1.8 won't switch threads here
+      end
+    end
+
+    Thread.pass until t.status == "sleep"
+
+    t.kill
+    t.alive? == true
+    exit = true
+    t.join
+  end
 end

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

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