diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2015-08-24 06:05:07 +0000 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2015-08-24 06:05:07 +0000 |
commit | 4f252cddc1ee4e28c633a2250335b2fac4d31108 (patch) | |
tree | 776177555c7039204e23c9c1b7d33b700d366ca3 /activesupport/lib/active_support/dependencies/interlock.rb | |
parent | bc36ffeec05692777f4ece09978a321feed2d818 (diff) | |
parent | 06818cb9a8cee8c95eaebdd1418e6fcb0da9382e (diff) | |
download | rails-4f252cddc1ee4e28c633a2250335b2fac4d31108.tar.gz rails-4f252cddc1ee4e28c633a2250335b2fac4d31108.tar.bz2 rails-4f252cddc1ee4e28c633a2250335b2fac4d31108.zip |
Merge branch 'master' of github.com:rails/rails
Conflicts:
guides/source/security.md
Diffstat (limited to 'activesupport/lib/active_support/dependencies/interlock.rb')
-rw-r--r-- | activesupport/lib/active_support/dependencies/interlock.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/dependencies/interlock.rb b/activesupport/lib/active_support/dependencies/interlock.rb index 148212c951..fbeb904684 100644 --- a/activesupport/lib/active_support/dependencies/interlock.rb +++ b/activesupport/lib/active_support/dependencies/interlock.rb @@ -4,21 +4,27 @@ module ActiveSupport #:nodoc: module Dependencies #:nodoc: class Interlock def initialize # :nodoc: - @lock = ActiveSupport::Concurrency::ShareLock.new(true) + @lock = ActiveSupport::Concurrency::ShareLock.new end def loading - @lock.exclusive do + @lock.exclusive(purpose: :load, compatible: [:load]) do yield end end - # Attempt to obtain a "loading" (exclusive) lock. If possible, + def unloading + @lock.exclusive(purpose: :unload, compatible: [:load, :unload]) do + yield + end + end + + # Attempt to obtain an "unloading" (exclusive) lock. If possible, # execute the supplied block while holding the lock. If there is # concurrent activity, return immediately (without executing the # block) instead of waiting. - def attempt_loading - @lock.exclusive(true) do + def attempt_unloading + @lock.exclusive(purpose: :unload, compatible: [:load, :unload], no_wait: true) do yield end end |