123456789_123456789_123456789_123456789_123456789_

Class: ActiveSupport::Concurrency::ThreadLoadInterlockAwareMonitor

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb

Constant Summary

LoadInterlockAwareMonitorMixin - Included

EXCEPTION_IMMEDIATE, EXCEPTION_NEVER

Class Method Summary

Instance Method Summary

LoadInterlockAwareMonitorMixin - Included

#mon_enter

Enters an exclusive section, but allows dependency loading while blocked.

#synchronize

Constructor Details

.newThreadLoadInterlockAwareMonitor

[ GitHub ]

  
# File 'activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb', line 39

def initialize
  @owner = nil
  @count = 0
  @mutex = Mutex.new
end

Instance Method Details

#mon_enter (private)

[ GitHub ]

  
# File 'activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb', line 54

def mon_enter
  @mutex.lock if @owner != Thread.current
  @owner = Thread.current
  @count += 1
end

#mon_exit (private)

[ GitHub ]

  
# File 'activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb', line 60

def mon_exit
  unless @owner == Thread.current
    raise ThreadError, "current thread not owner"
  end

  @count -= 1
  return unless @count == 0
  @owner = nil
  @mutex.unlock
end

#mon_try_enter (private)

[ GitHub ]

  
# File 'activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb', line 46

def mon_try_enter
  if @owner != Thread.current
    return false unless @mutex.try_lock
    @owner = Thread.current
  end
  @count += 1
end