class Citrus::Utils::CountDownLatch
Public Class Methods
new(count, args={})
click to toggle source
Create a count down latch
@param [Integer] count @param [Hash] args
# File lib/citrus/util/countdown_latch.rb, line 18 def initialize count, args={}, &block @count = count @block = block if args[:timeout] @timer = EM::Timer.new(args[:timeout]) { @block.respond_to? :call and @block.call true } end end
Public Instance Methods
done()
click to toggle source
Called when a task finish count down
# File lib/citrus/util/countdown_latch.rb, line 29 def done unless @count > 0 throw Exception.new 'illegal state' end @count -= 1 if @count == 0 @timer.cancel if @timer @block.respond_to? :call and @block.call end end