aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2014-09-30 01:46:07 +0930
committerMatthew Draper <matthew@trebex.net>2015-07-09 03:31:30 +0930
commit383fed5f232630c198847ec573821ede4cf267a9 (patch)
treee55cca58cf30b7dd03ca5506b9e99ab103677673 /activesupport/lib
parentc37d47e30897762145835e66ae752cce924af01d (diff)
downloadrails-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.rb10
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