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

ruby-changes:32548

From: nobu <ko1@a...>
Date: Thu, 16 Jan 2014 15:34:51 +0900 (JST)
Subject: [ruby-changes:32548] nobu:r44627 (trunk): test_thread.rb: stop at once

nobu	2014-01-16 15:34:47 +0900 (Thu, 16 Jan 2014)

  New Revision: 44627

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

  Log:
    test_thread.rb: stop at once
    
    * test/ruby/test_thread.rb (test_priority): stop both threads at
      once by a flag.

  Modified files:
    trunk/test/ruby/test_thread.rb
Index: test/ruby/test_thread.rb
===================================================================
--- test/ruby/test_thread.rb	(revision 44626)
+++ test/ruby/test_thread.rb	(revision 44627)
@@ -127,17 +127,21 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L127
 
   def test_priority
     c1 = c2 = 0
-    t1 = Thread.new { loop { c1 += 1 } }
+    run = true
+    t1 = Thread.new { c1 += 1 while run }
     t1.priority = 3
-    t2 = Thread.new { loop { c2 += 1 } }
+    t2 = Thread.new { c2 += 1 while run }
     t2.priority = -3
     assert_equal(3, t1.priority)
     assert_equal(-3, t2.priority)
     sleep 0.5
     5.times do
+      assert_not_predicate(t1, :stop?)
+      assert_not_predicate(t2, :stop?)
       break if c1 > c2
       sleep 0.1
     end
+    run = false
     t1.kill
     t2.kill
     assert_operator(c1, :>, c2, "[ruby-dev:33124]") # not guaranteed

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

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