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

ruby-changes:34193

From: akr <ko1@a...>
Date: Sat, 31 May 2014 09:01:37 +0900 (JST)
Subject: [ruby-changes:34193] akr:r46274 (trunk): Join threads.

akr	2014-05-31 09:01:32 +0900 (Sat, 31 May 2014)

  New Revision: 46274

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

  Log:
    Join threads.

  Modified files:
    trunk/test/test_pstore.rb
Index: test/test_pstore.rb
===================================================================
--- test/test_pstore.rb	(revision 46273)
+++ test/test_pstore.rb	(revision 46274)
@@ -77,28 +77,36 @@ class PStoreTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_pstore.rb#L77
   def test_thread_safe
     assert_raise(PStore::Error) do
       flag = false
-      Thread.new do
+      th = Thread.new do
         @pstore.transaction do
           @pstore[:foo] = "bar"
           flag = true
           sleep 1
         end
       end
-      sleep 0.1 until flag
-      @pstore.transaction {}
+      begin
+        sleep 0.1 until flag
+        @pstore.transaction {}
+      ensure
+        th.join
+      end
     end
     begin
       pstore = PStore.new(second_file, true)
       flag = false
-      Thread.new do
+      th = Thread.new do
         pstore.transaction do
           pstore[:foo] = "bar"
           flag = true
           sleep 1
         end
       end
-      sleep 0.1 until flag
-      assert_equal("bar", pstore.transaction { pstore[:foo] })
+      begin
+        sleep 0.1 until flag
+        assert_equal("bar", pstore.transaction { pstore[:foo] })
+      ensure
+        th.join
+      end
     end
   ensure
     File.unlink(second_file) rescue nil

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

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