Class: ActiveSupport::Dependencies::Interlock

Inherits:
Object
  • Object
show all
Defined in:
lib/active_support/dependencies/interlock.rb

Instance Method Summary collapse

Constructor Details

#initializeInterlock

:nodoc:



8
9
10
# File 'lib/active_support/dependencies/interlock.rb', line 8

def initialize # :nodoc:
  @lock = ActiveSupport::Concurrency::ShareLock.new
end

Instance Method Details

#done_runningObject



37
38
39
# File 'lib/active_support/dependencies/interlock.rb', line 37

def done_running
  @lock.stop_sharing
end

#done_unloadingObject



29
30
31
# File 'lib/active_support/dependencies/interlock.rb', line 29

def done_unloading
  @lock.stop_exclusive(compatible: [:unload])
end

#loading(&block) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/active_support/dependencies/interlock.rb', line 12

def loading(&block)
  ActiveSupport.deprecator.warn(
    "ActiveSupport::Dependencies::Interlock#loading is deprecated and " \
    "will be removed in Rails 9.0. The loading interlock is no longer " \
    "used since Rails switched to Zeitwerk for autoloading."
  )
  yield if block
end

#permit_concurrent_loads(&block) ⇒ Object



45
46
47
48
# File 'lib/active_support/dependencies/interlock.rb', line 45

def permit_concurrent_loads(&block)
  # Soft deprecated: no deprecation warning for now, but this is a no-op.
  yield if block
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(&block) ⇒ Object



41
42
43
# File 'lib/active_support/dependencies/interlock.rb', line 41

def running(&block)
  @lock.sharing(&block)
end

#start_runningObject



33
34
35
# File 'lib/active_support/dependencies/interlock.rb', line 33

def start_running
  @lock.start_sharing
end

#start_unloadingObject



25
26
27
# File 'lib/active_support/dependencies/interlock.rb', line 25

def start_unloading
  @lock.start_exclusive(purpose: :unload, compatible: [:unload])
end

#unloading(&block) ⇒ Object



21
22
23
# File 'lib/active_support/dependencies/interlock.rb', line 21

def unloading(&block)
  @lock.exclusive(purpose: :unload, compatible: [:unload], after_compatible: [:unload], &block)
end