diff options
author | wyhaines <wyhaines@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-08 16:35:10 +0000 |
---|---|---|
committer | wyhaines <wyhaines@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-08 16:35:10 +0000 |
commit | 13e40bdaa08d004edb45c2be872a812236296f31 (patch) | |
tree | f085e807f29f7859a588f0b5aefb061429086275 /test | |
parent | 885527dec71812e613ecd77b2cdfb7f448b52664 (diff) |
lib/monitor.rb: Backport #2240 [ruby-core:26185]; backport r25420 to ensure that the scheduled thread is alive when a monitor is released.
test/monitor/test_monitor.rb: Backport #2240 [ruby-core:26185]; added a test for the above functionality.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@28232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/monitor/test_monitor.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/monitor/test_monitor.rb b/test/monitor/test_monitor.rb index b539cb3cca..71d2ed19a5 100644 --- a/test/monitor/test_monitor.rb +++ b/test/monitor/test_monitor.rb @@ -54,6 +54,32 @@ class TestMonitor < Test::Unit::TestCase assert_equal((1..10).to_a, ary) end + def test_killed_thread_in_synchronize + ary = [] + queue = Queue.new + t1 = Thread.start { + queue.pop + @monitor.synchronize { + ary << :t1 + } + } + t2 = Thread.start { + queue.pop + @monitor.synchronize { + ary << :t2 + } + } + @monitor.synchronize do + queue.enq(nil) + queue.enq(nil) + assert_equal([], ary) + t1.kill + t2.kill + ary << :main + end + assert_equal([:main], ary) + end + def test_try_enter queue1 = Queue.new queue2 = Queue.new @@ -94,6 +120,10 @@ class TestMonitor < Test::Unit::TestCase assert_equal(true, result1) assert_equal("bar", a) end + end + + def test_timedwait + cond = @monitor.new_cond b = "foo" queue2 = Queue.new |