Class: ActiveSupport::Dependencies::Interlock
- Defined in:
- lib/active_support/dependencies/interlock.rb
Instance Method Summary collapse
- #done_running ⇒ Object
- #done_unloading ⇒ Object
-
#initialize ⇒ Interlock
constructor
:nodoc:.
- #loading ⇒ Object
- #permit_concurrent_loads ⇒ Object
-
#raw_state(&block) ⇒ Object
:nodoc:.
- #running ⇒ Object
- #start_running ⇒ Object
- #start_unloading ⇒ Object
- #unloading ⇒ Object
Constructor Details
#initialize ⇒ Interlock
:nodoc:
6 7 8 |
# File 'lib/active_support/dependencies/interlock.rb', line 6 def initialize # :nodoc: @lock = ActiveSupport::Concurrency::ShareLock.new end |
Instance Method Details
#done_running ⇒ Object
34 35 36 |
# File 'lib/active_support/dependencies/interlock.rb', line 34 def done_running @lock.stop_sharing end |
#done_unloading ⇒ Object
26 27 28 |
# File 'lib/active_support/dependencies/interlock.rb', line 26 def done_unloading @lock.stop_exclusive(compatible: [:load, :unload]) end |
#loading ⇒ Object
10 11 12 13 14 |
# File 'lib/active_support/dependencies/interlock.rb', line 10 def loading @lock.exclusive(purpose: :load, compatible: [:load], after_compatible: [:load]) do yield end end |
#permit_concurrent_loads ⇒ Object
44 45 46 47 48 |
# File 'lib/active_support/dependencies/interlock.rb', line 44 def permit_concurrent_loads @lock.yield_shares(compatible: [:load]) do yield end end |
#raw_state(&block) ⇒ Object
:nodoc:
50 51 52 |
# File 'lib/active_support/dependencies/interlock.rb', line 50 def raw_state(&block) # :nodoc: @lock.raw_state(&block) end |
#running ⇒ Object
38 39 40 41 42 |
# File 'lib/active_support/dependencies/interlock.rb', line 38 def running @lock.sharing do yield end end |
#start_running ⇒ Object
30 31 32 |
# File 'lib/active_support/dependencies/interlock.rb', line 30 def start_running @lock.start_sharing end |
#start_unloading ⇒ Object
22 23 24 |
# File 'lib/active_support/dependencies/interlock.rb', line 22 def start_unloading @lock.start_exclusive(purpose: :unload, compatible: [:load, :unload]) end |
#unloading ⇒ Object
16 17 18 19 20 |
# File 'lib/active_support/dependencies/interlock.rb', line 16 def unloading @lock.exclusive(purpose: :unload, compatible: [:load, :unload], after_compatible: [:load, :unload]) do yield end end |