diff options
author | Matthew Draper <matthew@trebex.net> | 2014-09-30 01:46:07 +0930 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2015-07-09 03:31:30 +0930 |
commit | 383fed5f232630c198847ec573821ede4cf267a9 (patch) | |
tree | e55cca58cf30b7dd03ca5506b9e99ab103677673 /activesupport/lib | |
parent | c37d47e30897762145835e66ae752cce924af01d (diff) | |
download | rails-383fed5f232630c198847ec573821ede4cf267a9.tar.gz rails-383fed5f232630c198847ec573821ede4cf267a9.tar.bz2 rails-383fed5f232630c198847ec573821ede4cf267a9.zip |
Rely on the load interlock for non-caching reloads, too
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/dependencies/interlock.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/dependencies/interlock.rb b/activesupport/lib/active_support/dependencies/interlock.rb index c3601bac13..035802d680 100644 --- a/activesupport/lib/active_support/dependencies/interlock.rb +++ b/activesupport/lib/active_support/dependencies/interlock.rb @@ -13,6 +13,16 @@ module ActiveSupport end end + # Attempt to obtain a "loading" (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 + yield + end + end + def start_running @lock.start_sharing end |