diff options
author | Matthew Draper <matthew@trebex.net> | 2016-02-22 11:55:52 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-03-02 02:14:20 +1030 |
commit | d3c9d808e3e242155a44fd2a89ef272cfade8fe8 (patch) | |
tree | f24199aec76f44fa8b6536c0664382672ad10e10 /activesupport/lib/active_support/dependencies | |
parent | 664a13e6fb8281107da0da75e7cd91bba1425f76 (diff) | |
download | rails-d3c9d808e3e242155a44fd2a89ef272cfade8fe8.tar.gz rails-d3c9d808e3e242155a44fd2a89ef272cfade8fe8.tar.bz2 rails-d3c9d808e3e242155a44fd2a89ef272cfade8fe8.zip |
Publish AS::Executor and AS::Reloader APIs
These should allow external code to run blocks of user code to do
"work", at a similar unit size to a web request, without needing to get
intimate with ActionDipatch.
Diffstat (limited to 'activesupport/lib/active_support/dependencies')
-rw-r--r-- | activesupport/lib/active_support/dependencies/interlock.rb | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/dependencies/interlock.rb b/activesupport/lib/active_support/dependencies/interlock.rb index 47bcecbb35..f1865ca2f8 100644 --- a/activesupport/lib/active_support/dependencies/interlock.rb +++ b/activesupport/lib/active_support/dependencies/interlock.rb @@ -19,14 +19,12 @@ module ActiveSupport #:nodoc: 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_unloading - @lock.exclusive(purpose: :unload, compatible: [:load, :unload], after_compatible: [:load, :unload], no_wait: true) do - yield - end + def start_unloading + @lock.start_exclusive(purpose: :unload, compatible: [:load, :unload]) + end + + def done_unloading + @lock.stop_exclusive(compatible: [:load, :unload]) end def start_running |