Class: ActiveSupport::Concurrency::Latch

Inherits:
Object
  • Object
show all
Defined in:
lib/active_support/concurrency/latch.rb

Instance Method Summary collapse

Constructor Details

#initialize(count = 1) ⇒ Latch

Returns a new instance of Latch.



7
8
9
10
11
12
13
14
15
# File 'lib/active_support/concurrency/latch.rb', line 7

def initialize(count = 1)
  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

Instance Method Details

#awaitObject



21
22
23
# File 'lib/active_support/concurrency/latch.rb', line 21

def await
  @inner.wait(nil)
end

#releaseObject



17
18
19
# File 'lib/active_support/concurrency/latch.rb', line 17

def release
  @inner.count_down
end