Class: RSpec::Support::ReentrantMutex
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/reentrant_mutex.rb
Overview
Allows a thread to lock out other threads from a critical section of code, while allowing the thread with the lock to reenter that section.
Based on Monitor as of 2.2 - github.com/ruby/ruby/blob/eb7ddaa3a47bf48045d26c72eb0f263a53524ebc/lib/monitor.rb#L9
Depends on Mutex, but Mutex is only available as part of core since 1.9.1:
exists - http://ruby-doc.org/core-1.9.1/Mutex.html
dne - http://ruby-doc.org/core-1.9.0/Mutex.html
Instance Method Summary collapse
-
#initialize ⇒ ReentrantMutex
constructor
A new instance of ReentrantMutex.
- #synchronize ⇒ Object
Constructor Details
#initialize ⇒ ReentrantMutex
Returns a new instance of ReentrantMutex.
15 16 17 18 19 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/reentrant_mutex.rb', line 15 def initialize @owner = nil @count = 0 @mutex = Mutex.new end |
Instance Method Details
#synchronize ⇒ Object
21 22 23 24 25 26 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/reentrant_mutex.rb', line 21 def synchronize enter yield ensure exit end |