diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-09-05 16:26:24 +1200 |
---|---|---|
committer | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2020-09-14 16:44:09 +1200 |
commit | 178c1b0922dc727897d81d7cfe9c97d5ffa97fd9 (patch) | |
tree | 113600e7e6a196b779bcac7529535597858f78a7 /spec | |
parent | 9e0a48c7a31ecd39be0596d0517b9d521ae75282 (diff) |
Make Mutex per-Fiber instead of per-Thread
* Enables Mutex to be used as synchronization between multiple Fibers
of the same Thread.
* With a Fiber scheduler we can yield to another Fiber on contended
Mutex#lock instead of blocking the entire thread.
* This also makes the behavior of Mutex consistent across CRuby, JRuby and TruffleRuby.
* [Feature #16792]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3434
Diffstat (limited to 'spec')
-rw-r--r-- | spec/ruby/core/mutex/owned_spec.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/ruby/core/mutex/owned_spec.rb b/spec/ruby/core/mutex/owned_spec.rb index e66062534e..f881622965 100644 --- a/spec/ruby/core/mutex/owned_spec.rb +++ b/spec/ruby/core/mutex/owned_spec.rb @@ -40,4 +40,16 @@ describe "Mutex#owned?" do m.owned?.should be_false end end + + ruby_version_is "2.8" do + it "is held per Fiber" do + m = Mutex.new + m.lock + + Fiber.new do + m.locked?.should == true + m.owned?.should == false + end.resume + end + end end |