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



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

def done_running
  @lock.stop_sharing
end

#done_unloadingObject



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

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

#loadingObject



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

def loading
  @lock.exclusive(purpose: :load, compatible: [:load], after_compatible: [:load]) do
    yield
  end
end

#permit_concurrent_loadsObject



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

def permit_concurrent_loads
  @lock.yield_shares(compatible: [:load]) do
    yield
  end
end

#raw_state(&block) ⇒ Object

:nodoc:



52
53
54
# File 'lib/active_support/dependencies/interlock.rb', line 52

def raw_state(&block) # :nodoc:
  @lock.raw_state(&block)
end

#runningObject



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

def running
  @lock.sharing do
    yield
  end
end

#start_runningObject



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

def start_running
  @lock.start_sharing
end

#start_unloadingObject



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

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

#unloadingObject



18
19
20
21
22
# File 'lib/active_support/dependencies/interlock.rb', line 18

def unloading
  @lock.exclusive(purpose: :unload, compatible: [:load, :unload], after_compatible: [:load, :unload]) do
    yield
  end
end