Sha256: 89d4694efedfc59f5bfd70af1d29236c60b60cdbcb46eb0690e9abff3ef84659

Contents?: true

Size: 609 Bytes

Versions: 13

Compression:

Stored size: 609 Bytes

Contents

module BigBrother
  class Ticker

    def self.pause(&block)
      EM.cancel_timer(@timer)

      while @outstanding_ticks > 0
        EM::Synchrony.sleep(0.1)
      end

      block.call
      schedule!
    end

    def self.schedule!
      @outstanding_ticks = 0
      @timer = EM::Synchrony.add_periodic_timer(0.1, &method(:tick))
    end

    def self.tick
      @outstanding_ticks += 1
      BigBrother.clusters.ready_for_check.each do |cluster|
        BigBrother.logger.debug("Monitoring cluster #{cluster.name}")
        cluster.monitor_nodes
      end
      @outstanding_ticks -= 1
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
big_brother-0.8.8.1 lib/big_brother/ticker.rb
big_brother-0.8.8 lib/big_brother/ticker.rb
big_brother-0.8.7 lib/big_brother/ticker.rb
big_brother-0.6.8 lib/big_brother/ticker.rb
big_brother-0.6.7 lib/big_brother/ticker.rb
big_brother-0.6.6 lib/big_brother/ticker.rb
big_brother-0.6.5 lib/big_brother/ticker.rb
big_brother-0.6.4 lib/big_brother/ticker.rb
big_brother-0.6.3 lib/big_brother/ticker.rb
big_brother-0.6.2 lib/big_brother/ticker.rb
big_brother-0.6.1 lib/big_brother/ticker.rb
big_brother-0.6.0 lib/big_brother/ticker.rb
big_brother-0.5.0 lib/big_brother/ticker.rb