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

ruby-changes:24452

From: naruse <ko1@a...>
Date: Tue, 24 Jul 2012 04:04:24 +0900 (JST)
Subject: [ruby-changes:24452] naruse:r36503 (trunk): Synchronize with simple variable assignment.

naruse	2012-07-24 04:04:15 +0900 (Tue, 24 Jul 2012)

  New Revision: 36503

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

  Log:
    Synchronize with simple variable assignment.
    
    If it uses Queue, Mutex#synchronize may suppress the exception caused by
    th.raise. The case happens when Ruby switches the thread after it pushes :go
    into q, in `self.unlock rescue nil`. The exception is rescued the
    `rescue nil`.

  Modified files:
    trunk/test/ruby/test_thread.rb

Index: test/ruby/test_thread.rb
===================================================================
--- test/ruby/test_thread.rb	(revision 36502)
+++ test/ruby/test_thread.rb	(revision 36503)
@@ -618,23 +618,22 @@
 
   def make_control_interrupt_test_thread1 flag
     r = []
-    q = Queue.new
+    ready_p = false
     th = Thread.new{
       begin
         Thread.control_interrupt(RuntimeError => flag){
-          q << :go
           begin
+            ready_p = true
             sleep 0.5
           rescue
             r << :c1
           end
         }
-        sleep 0.5
       rescue
         r << :c2
       end
     }
-    q.pop # wait
+    Thread.pass until ready_p
     th.raise
     begin
       th.join

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

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