diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 01:40:53 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 01:40:53 +0000 |
commit | da1b14bcec60c607bd1a6a782b44573b1fa14b52 (patch) | |
tree | 9e5660ba720d16f54167e2bef4f48dfc5ddbf7be /test/monitor/test_monitor.rb | |
parent | 79e0a19353a6015cb653a9cfc078203bf296da0b (diff) | |
download | ruby-da1b14bcec60c607bd1a6a782b44573b1fa14b52.tar.gz |
Add MonitorMinx#mon_locked? and #mon_owned? to check states of objects
Patched by Satoshi "Moris" Tagomori <tagomoris@gmail.com>. [Fix GH-1699]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/monitor/test_monitor.rb')
-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 a3861735b3..ca45602637 100644 --- a/test/monitor/test_monitor.rb +++ b/test/monitor/test_monitor.rb @@ -146,6 +146,35 @@ class TestMonitor < Test::Unit::TestCase assert_join_threads([th, th2]) end + def test_mon_locked_and_owned + queue1 = Queue.new + queue2 = Queue.new + th = Thread.start { + @monitor.enter + queue1.enq(nil) + queue2.deq + @monitor.exit + queue1.enq(nil) + } + queue1.deq + assert(@monitor.mon_locked?) + assert(!@monitor.mon_owned?) + + queue2.enq(nil) + queue1.deq + assert(!@monitor.mon_locked?) + + @monitor.enter + assert @monitor.mon_locked? + assert @monitor.mon_owned? + @monitor.exit + + @monitor.synchronize do + assert @monitor.mon_locked? + assert @monitor.mon_owned? + end + end + def test_cond cond = @monitor.new_cond |