diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-29 07:19:32 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-29 07:19:32 +0000 |
| commit | b3706a2f39057378e0b40c0acbc1deb89c820735 (patch) | |
| tree | c2d478f0bb22a5f7fada4c6e71943803c160d4ae /test/ruby/test_thread.rb | |
| parent | 31dfe94360f3b65516ed9963c81d1760bd9fd4b6 (diff) | |
merges r21148 from trunk into ruby_1_9_1.
* thread.c (rb_mutex_trylock): return false if Mutex owned
by current thread. [ruby-core:20943]
* thread.c (rb_mutex_lock): check dead lock (recursive lock) here.
* test/ruby/test_thread.rb: add a test.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@21160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_thread.rb')
| -rw-r--r-- | test/ruby/test_thread.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 97e58cd9e..b460cadea 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -438,6 +438,18 @@ class TestThread < Test::Unit::TestCase assert_equal(false, m3.locked?) end + def test_mutex_trylock + m = Mutex.new + assert_equal(true, m.try_lock) + assert_equal(false, m.try_lock, '[ruby-core:20943]') + + Thread.new{ + assert_equal(false, m.try_lock) + }.join + + m.unlock + end + def test_recursive_error o = Object.new def o.inspect |
