aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/concurrency
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/concurrency')
-rw-r--r--activesupport/lib/active_support/concurrency/latch.rb3
-rw-r--r--activesupport/lib/active_support/concurrency/share_lock.rb39
2 files changed, 20 insertions, 22 deletions
diff --git a/activesupport/lib/active_support/concurrency/latch.rb b/activesupport/lib/active_support/concurrency/latch.rb
index 35074265b8..53e09b685c 100644
--- a/activesupport/lib/active_support/concurrency/latch.rb
+++ b/activesupport/lib/active_support/concurrency/latch.rb
@@ -1,9 +1,8 @@
-require 'concurrent/atomic/count_down_latch'
+require "concurrent/atomic/count_down_latch"
module ActiveSupport
module Concurrency
class Latch
-
def initialize(count = 1)
if count == 1
ActiveSupport::Deprecation.warn("ActiveSupport::Concurrency::Latch is deprecated. Please use Concurrent::Event instead.")
diff --git a/activesupport/lib/active_support/concurrency/share_lock.rb b/activesupport/lib/active_support/concurrency/share_lock.rb
index cf632ea7b0..8969ebb080 100644
--- a/activesupport/lib/active_support/concurrency/share_lock.rb
+++ b/activesupport/lib/active_support/concurrency/share_lock.rb
@@ -1,5 +1,5 @@
-require 'thread'
-require 'monitor'
+require "thread"
+require "monitor"
module ActiveSupport
module Concurrency
@@ -13,7 +13,6 @@ module ActiveSupport
# we need exclusive locks to be reentrant, and we need to be able
# to upgrade share locks to exclusive.
-
def raw_state # :nodoc:
synchronize do
threads = @sleeping.keys | @sharing.keys | @waiting.keys
@@ -201,26 +200,26 @@ module ActiveSupport
private
# Must be called within synchronize
- def busy_for_exclusive?(purpose)
- busy_for_sharing?(purpose) ||
- @sharing.size > (@sharing[Thread.current] > 0 ? 1 : 0)
- end
+ def busy_for_exclusive?(purpose)
+ busy_for_sharing?(purpose) ||
+ @sharing.size > (@sharing[Thread.current] > 0 ? 1 : 0)
+ end
- def busy_for_sharing?(purpose)
- (@exclusive_thread && @exclusive_thread != Thread.current) ||
- @waiting.any? { |t, (_, c)| t != Thread.current && !c.include?(purpose) }
- end
+ def busy_for_sharing?(purpose)
+ (@exclusive_thread && @exclusive_thread != Thread.current) ||
+ @waiting.any? { |t, (_, c)| t != Thread.current && !c.include?(purpose) }
+ end
- def eligible_waiters?(compatible)
- @waiting.any? { |t, (p, _)| compatible.include?(p) && @waiting.all? { |t2, (_, c2)| t == t2 || c2.include?(p) } }
- end
+ def eligible_waiters?(compatible)
+ @waiting.any? { |t, (p, _)| compatible.include?(p) && @waiting.all? { |t2, (_, c2)| t == t2 || c2.include?(p) } }
+ end
- def wait_for(method)
- @sleeping[Thread.current] = method
- @cv.wait_while { yield }
- ensure
- @sleeping.delete Thread.current
- end
+ def wait_for(method)
+ @sleeping[Thread.current] = method
+ @cv.wait_while { yield }
+ ensure
+ @sleeping.delete Thread.current
+ end
end
end
end