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

ruby-changes:34207

From: akr <ko1@a...>
Date: Mon, 2 Jun 2014 09:21:40 +0900 (JST)
Subject: [ruby-changes:34207] akr:r46286 (trunk): Join threads.

akr	2014-06-01 00:31:46 +0900 (Sun, 01 Jun 2014)

  New Revision: 46286

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

  Log:
    Join threads.

  Modified files:
    trunk/test/monitor/test_monitor.rb
    trunk/test/ruby/test_file.rb
    trunk/test/ruby/test_process.rb
Index: test/ruby/test_file.rb
===================================================================
--- test/ruby/test_file.rb	(revision 46285)
+++ test/ruby/test_file.rb	(revision 46286)
@@ -124,7 +124,7 @@ class TestFile < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file.rb#L124
       q1 = Queue.new
       q2 = Queue.new
 
-      Thread.new do
+      th = Thread.new do
         data = ''
         64.times do |i|
           data << i.to_s
@@ -142,6 +142,7 @@ class TestFile < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file.rb#L142
         assert_equal size, f.size
         q2.push true
       end
+      th.join
     end
   end
 
Index: test/ruby/test_process.rb
===================================================================
--- test/ruby/test_process.rb	(revision 46285)
+++ test/ruby/test_process.rb	(revision 46286)
@@ -1237,8 +1237,9 @@ class TestProcess < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L1237
       IO.pipe do |r, w|
         pid = spawn(RUBY, "foo", out: w)
         w.close
-        Thread.new { r.read(1); Process.kill(:SIGQUIT, pid) }
+        th = Thread.new { r.read(1); Process.kill(:SIGQUIT, pid) }
         Process.wait(pid)
+        th.join
       end
       t = Time.now
       s = $?
Index: test/monitor/test_monitor.rb
===================================================================
--- test/monitor/test_monitor.rb	(revision 46285)
+++ test/monitor/test_monitor.rb	(revision 46286)
@@ -86,7 +86,7 @@ class TestMonitor < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/monitor/test_monitor.rb#L86
   def test_try_enter
     queue1 = Queue.new
     queue2 = Queue.new
-    Thread.start {
+    th = Thread.start {
       queue1.deq
       @monitor.enter
       queue2.enq(nil)
@@ -102,6 +102,7 @@ class TestMonitor < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/monitor/test_monitor.rb#L102
     queue1.enq(nil)
     queue2.deq
     assert_equal(true, @monitor.try_enter)
+    th.join
   end
 
   def test_cond
@@ -109,7 +110,7 @@ class TestMonitor < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/monitor/test_monitor.rb#L110
 
     a = "foo"
     queue1 = Queue.new
-    Thread.start do
+    th = Thread.start do
       queue1.deq
       @monitor.synchronize do
         a = "bar"
@@ -123,13 +124,14 @@ class TestMonitor < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/monitor/test_monitor.rb#L124
       assert_equal(true, result1)
       assert_equal("bar", a)
     end
+    th.join
   end
 
   def test_timedwait
     cond = @monitor.new_cond
     b = "foo"
     queue2 = Queue.new
-    Thread.start do
+    th = Thread.start do
       queue2.deq
       @monitor.synchronize do
         b = "bar"
@@ -143,10 +145,11 @@ class TestMonitor < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/monitor/test_monitor.rb#L145
       assert_equal(true, result2)
       assert_equal("bar", b)
     end
+    th.join
 
     c = "foo"
     queue3 = Queue.new
-    Thread.start do
+    th = Thread.start do
       queue3.deq
       @monitor.synchronize do
         c = "bar"
@@ -163,6 +166,7 @@ class TestMonitor < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/monitor/test_monitor.rb#L166
       assert_equal(true, result4)
       assert_equal("bar", c)
     end
+    th.join
 
 #     d = "foo"
 #     cumber_thread = Thread.start {

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

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