diff options
author | Matthew Draper <matthew@trebex.net> | 2016-07-02 06:47:38 +0930 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-02 06:47:38 +0930 |
commit | f0c7e2b8c373d36d2a04cce14b9243ea9b67f950 (patch) | |
tree | 8679ba7ab0b3e86e7fc3e42b11a247f5e7e33bf2 /activesupport | |
parent | 803ee80c88e04f1d9e81ca0dc7e71986b81784af (diff) | |
parent | b50f5a5ac6fc554eaad3138cb42f678a41794771 (diff) | |
download | rails-f0c7e2b8c373d36d2a04cce14b9243ea9b67f950.tar.gz rails-f0c7e2b8c373d36d2a04cce14b9243ea9b67f950.tar.bz2 rails-f0c7e2b8c373d36d2a04cce14b9243ea9b67f950.zip |
Merge pull request #24146 from matthewd/latch-as-proxy
Don't inherit from Concurrent::CountDownLatch
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/concurrency/latch.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/concurrency/latch.rb b/activesupport/lib/active_support/concurrency/latch.rb index 4abe5ece6f..35074265b8 100644 --- a/activesupport/lib/active_support/concurrency/latch.rb +++ b/activesupport/lib/active_support/concurrency/latch.rb @@ -2,17 +2,24 @@ require 'concurrent/atomic/count_down_latch' module ActiveSupport module Concurrency - class Latch < Concurrent::CountDownLatch + class Latch def initialize(count = 1) - ActiveSupport::Deprecation.warn("ActiveSupport::Concurrency::Latch is deprecated. Please use Concurrent::CountDownLatch instead.") - super(count) + if count == 1 + ActiveSupport::Deprecation.warn("ActiveSupport::Concurrency::Latch is deprecated. Please use Concurrent::Event instead.") + else + ActiveSupport::Deprecation.warn("ActiveSupport::Concurrency::Latch is deprecated. Please use Concurrent::CountDownLatch instead.") + end + + @inner = Concurrent::CountDownLatch.new(count) end - alias_method :release, :count_down + def release + @inner.count_down + end def await - wait(nil) + @inner.wait(nil) end end end |