diff options
author | Benoit Daloze <[email protected]> | 2021-07-29 22:11:21 +0200 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2021-07-29 22:11:21 +0200 |
commit | 6998d758248d778fa95b008c78d05473e48b8428 (patch) | |
tree | 8abc6926f647ea5f374a5b34c3a4820c5861e32e /spec/ruby/library/monitor/enter_spec.rb | |
parent | 15d05f8120745a121b93fab9fd2addf5f094e8d2 (diff) |
Update to ruby/spec@b65d01f
Diffstat (limited to 'spec/ruby/library/monitor/enter_spec.rb')
-rw-r--r-- | spec/ruby/library/monitor/enter_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/ruby/library/monitor/enter_spec.rb b/spec/ruby/library/monitor/enter_spec.rb new file mode 100644 index 0000000000..f523c42087 --- /dev/null +++ b/spec/ruby/library/monitor/enter_spec.rb @@ -0,0 +1,28 @@ +require_relative '../../spec_helper' +require 'monitor' + +describe "Monitor#enter" do + it "acquires the monitor" do + monitor = Monitor.new + 10.times do + wait_q = Queue.new + continue_q = Queue.new + + thread = Thread.new do + begin + monitor.enter + wait_q << true + continue_q.pop + ensure + monitor.exit + end + end + + wait_q.pop + monitor.mon_locked?.should == true + continue_q << true + thread.join + monitor.mon_locked?.should == false + end + end +end |