diff options
| author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-20 16:14:25 +0000 |
|---|---|---|
| committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-20 16:14:25 +0000 |
| commit | 69743fbd85b659601174bff9fb61abc8c662c13b (patch) | |
| tree | c06507b2a51f4afa05bf543ef97af6a0a23e58f4 /test | |
| parent | 3b33b909d458f4333c50337f36be4abc1f038b47 (diff) | |
* lib/monitor.rb (MonitorMixin.mon_release): ensure the scheduled
thread to be alive when a thread is releasing a monitor. #2240
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
| -rw-r--r-- | test/monitor/test_monitor.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/monitor/test_monitor.rb b/test/monitor/test_monitor.rb index b539cb3cca..7593d3f938 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,7 +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 Thread.start do |
