diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-02-06 09:14:40 +0900 |
|---|---|---|
| committer | Jeremy Evans <code@jeremyevans.net> | 2021-07-25 13:09:03 -0700 |
| commit | 070557afc4ca83876b951fe090806b59e3867ae5 (patch) | |
| tree | 9756aa96026efd552184011ad45c05f2027e19aa /test/ruby/test_thread_cv.rb | |
| parent | 8897098b5ca3ce987307d1799f7765e6a279ff0d (diff) | |
Distinguish signal and timeout [Bug #16608]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4256
Diffstat (limited to 'test/ruby/test_thread_cv.rb')
| -rw-r--r-- | test/ruby/test_thread_cv.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/ruby/test_thread_cv.rb b/test/ruby/test_thread_cv.rb index 5f19b85bc0..812c4221bc 100644 --- a/test/ruby/test_thread_cv.rb +++ b/test/ruby/test_thread_cv.rb @@ -16,6 +16,7 @@ class TestThreadConditionVariable < Test::Unit::TestCase mutex = Thread::Mutex.new condvar = Thread::ConditionVariable.new result = [] + woken = nil mutex.synchronize do t = Thread.new do mutex.synchronize do @@ -25,11 +26,12 @@ class TestThreadConditionVariable < Test::Unit::TestCase end result << 0 - condvar.wait(mutex) + woken = condvar.wait(mutex) result << 2 t.join end assert_equal([0, 1, 2], result) + assert(woken) end def test_condvar_wait_exception_handling @@ -140,11 +142,12 @@ INPUT condvar = Thread::ConditionVariable.new timeout = 0.3 locked = false + woken = true t0 = Time.now mutex.synchronize do begin - condvar.wait(mutex, timeout) + woken = condvar.wait(mutex, timeout) ensure locked = mutex.locked? end @@ -154,6 +157,7 @@ INPUT assert_operator(timeout*0.9, :<, t) assert(locked) + assert_nil(woken) end def test_condvar_nolock |
