Skip to content

Commit c6beb6d

Browse files
committed
Merge pull request rails#24146 from matthewd/latch-as-proxy
Don't inherit from Concurrent::CountDownLatch
1 parent 5a553f3 commit c6beb6d

File tree

1 file changed

+12
-5
lines changed
  • activesupport/lib/active_support/concurrency

1 file changed

+12
-5
lines changed

activesupport/lib/active_support/concurrency/latch.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@
22

33
module ActiveSupport
44
module Concurrency
5-
class Latch < Concurrent::CountDownLatch
5+
class Latch
66

77
def initialize(count = 1)
8-
ActiveSupport::Deprecation.warn("ActiveSupport::Concurrency::Latch is deprecated. Please use Concurrent::CountDownLatch instead.")
9-
super(count)
8+
if count == 1
9+
ActiveSupport::Deprecation.warn("ActiveSupport::Concurrency::Latch is deprecated. Please use Concurrent::Event instead.")
10+
else
11+
ActiveSupport::Deprecation.warn("ActiveSupport::Concurrency::Latch is deprecated. Please use Concurrent::CountDownLatch instead.")
12+
end
13+
14+
@inner = Concurrent::CountDownLatch.new(count)
1015
end
1116

12-
alias_method :release, :count_down
17+
def release
18+
@inner.count_down
19+
end
1320

1421
def await
15-
wait(nil)
22+
@inner.wait(nil)
1623
end
1724
end
1825
end

0 commit comments

Comments
 (0)