diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-04-03 09:44:40 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-04-03 09:44:40 +0900 |
commit | 18f7d3c9a647f31f11e182d900b88edf5e34ea4b (patch) | |
tree | 8eb67d6720e79022a9102ffb5c4e17155f324995 /spec/ruby/library/conditionvariable/wait_spec.rb | |
parent | f49a24201c8bbcf9fcb4349174e468a673d14b98 (diff) |
Refined "Drop support for ruby 2.4 from ruby/spec"
By using spec/mspec/tool/remove_old_guards.rb.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2997
Diffstat (limited to 'spec/ruby/library/conditionvariable/wait_spec.rb')
-rw-r--r-- | spec/ruby/library/conditionvariable/wait_spec.rb | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/spec/ruby/library/conditionvariable/wait_spec.rb b/spec/ruby/library/conditionvariable/wait_spec.rb index b545c6c15e..9a68c2b5a1 100644 --- a/spec/ruby/library/conditionvariable/wait_spec.rb +++ b/spec/ruby/library/conditionvariable/wait_spec.rb @@ -106,41 +106,39 @@ describe "ConditionVariable#wait" do owned.should == true end - ruby_bug '#14999', ''...'2.5' do - it "reacquires the lock even if the thread is killed after being signaled" do - m = Mutex.new - cv = ConditionVariable.new - in_synchronize = false - owned = nil - - th = Thread.new do - m.synchronize do - in_synchronize = true - begin - cv.wait(m) - ensure - owned = m.owned? - $stderr.puts "\nThe Thread doesn't own the Mutex!" unless owned - end + it "reacquires the lock even if the thread is killed after being signaled" do + m = Mutex.new + cv = ConditionVariable.new + in_synchronize = false + owned = nil + + th = Thread.new do + m.synchronize do + in_synchronize = true + begin + cv.wait(m) + ensure + owned = m.owned? + $stderr.puts "\nThe Thread doesn't own the Mutex!" unless owned end end + end - # wait for m to acquire the mutex - Thread.pass until in_synchronize - # wait until th is sleeping (ie waiting) - Thread.pass until th.stop? - - m.synchronize { - cv.signal - # Wait that the thread is blocked on acquiring the Mutex - sleep 0.001 - # Kill the thread, yet the thread should first acquire the Mutex before going on - th.kill - } + # wait for m to acquire the mutex + Thread.pass until in_synchronize + # wait until th is sleeping (ie waiting) + Thread.pass until th.stop? - th.join - owned.should == true - end + m.synchronize { + cv.signal + # Wait that the thread is blocked on acquiring the Mutex + sleep 0.001 + # Kill the thread, yet the thread should first acquire the Mutex before going on + th.kill + } + + th.join + owned.should == true end it "supports multiple Threads waiting on the same ConditionVariable and Mutex" do |