aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb
blob: a8455c00483f7bd47b14b9f0236a95c60c661780 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 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
      # Enters an exclusive section, but allows dependency loading while blocked
      def mon_enter
        mon_try_enter ||
          ActiveSupport::Dependencies.interlock.permit_concurrent_loads { super }
      end
    end
  end
end