mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test/thread: fix leaked threads
* test/thread/test_{queue,sync}.rb: join work threads not to leak threads. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
00f78058b6
commit
501afa0134
2 changed files with 15 additions and 0 deletions
|
@ -62,6 +62,8 @@ class TestQueue < Test::Unit::TestCase
|
|||
sleep 0.01 until t1.stop?
|
||||
q.max = q.max + 1
|
||||
assert_equal before + 1, q.max
|
||||
ensure
|
||||
t1.join if t1
|
||||
end
|
||||
|
||||
def test_queue_pop_interrupt
|
||||
|
@ -206,6 +208,13 @@ class TestQueue < Test::Unit::TestCase
|
|||
assert_nothing_raised(TimeoutError) do
|
||||
timeout(1) { th2.join }
|
||||
end
|
||||
ensure
|
||||
[th1, th2].each do |th|
|
||||
if th and th.alive?
|
||||
th.wakeup
|
||||
th.join
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_dup
|
||||
|
|
|
@ -19,6 +19,9 @@ class SyncTest < Test::Unit::TestCase
|
|||
sleep 0.1 until t.stop?
|
||||
|
||||
assert_equal(tester.sync_waiting.uniq, tester.sync_waiting)
|
||||
ensure
|
||||
t.kill
|
||||
t.join
|
||||
end
|
||||
|
||||
def test_sync_upgrade_and_wakeup
|
||||
|
@ -39,6 +42,9 @@ class SyncTest < Test::Unit::TestCase
|
|||
}
|
||||
assert_equal(tester.sync_waiting.uniq, tester.sync_waiting)
|
||||
assert_equal(tester.sync_waiting, [])
|
||||
ensure
|
||||
t.kill
|
||||
t.join
|
||||
end
|
||||
|
||||
def test_sync_lock_and_raise
|
||||
|
|
Loading…
Reference in a new issue