Sha256: 15c9e2a6d47aaaa476daa91d36cc21a6e1bf7d955ac65b565fd1e1c8587a45e3

Contents?: true

Size: 931 Bytes

Versions: 70

Compression:

Stored size: 931 Bytes

Contents

# frozen_string_literal: true

require "monitor"

module ActiveSupport
  module Concurrency
    # A monitor that will permit dependency loading while blocked waiting for
    # the lock.
    class LoadInterlockAwareMonitor < Monitor
      EXCEPTION_NEVER = { Exception => :never }.freeze
      EXCEPTION_IMMEDIATE = { Exception => :immediate }.freeze
      private_constant :EXCEPTION_NEVER, :EXCEPTION_IMMEDIATE

      # Enters an exclusive section, but allows dependency loading while blocked
      def mon_enter
        mon_try_enter ||
          ActiveSupport::Dependencies.interlock.permit_concurrent_loads { super }
      end

      def synchronize
        Thread.handle_interrupt(EXCEPTION_NEVER) do
          mon_enter

          begin
            Thread.handle_interrupt(EXCEPTION_IMMEDIATE) do
              yield
            end
          ensure
            mon_exit
          end
        end
      end
    end
  end
end

Version data entries

70 entries across 70 versions & 9 rubygems

Version Path
activesupport-6.1.7.10 lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.1.7.9 lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.1.7.8 lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.1.7.7 lib/active_support/concurrency/load_interlock_aware_monitor.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.1.7.6 lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.1.7.5 lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.1.7.4 lib/active_support/concurrency/load_interlock_aware_monitor.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb
mumukit-content-type-1.12.1 vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb
mumukit-content-type-1.12.0 vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.6.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.1.7.3 lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.1.7.2 lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.1.7.1 lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.0.6.1 lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.1.7 lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.0.6 lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.1.6.1 lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-6.0.5.1 lib/active_support/concurrency/load_interlock_aware_monitor.rb
activesupport-5.2.8.1 lib/active_support/concurrency/load_interlock_aware_monitor.rb