Sha256: 0d6132678274de568375fa7c0408e2359f35168d07e1191f31b5a87f95bdeb7f

Contents?: true

Size: 552 Bytes

Versions: 266

Compression:

Stored size: 552 Bytes

Contents

module FSSM::Backends
  class Polling
    def initialize(options={})
      @handlers = []
      @latency  = options[:latency] || 1.5
    end

    def add_handler(handler, preload=true)
      handler.refresh(nil, true) if preload
      @handlers << handler
    end

    def run
      begin
        loop do
          start = Time.now.to_f
          @handlers.each { |handler| handler.refresh }
          nap_time = @latency - (Time.now.to_f - start)
          sleep nap_time if nap_time > 0
        end
      rescue Interrupt
      end
    end
  end
end

Version data entries

266 entries across 119 versions & 8 rubygems

Version Path
sass-3.1.6 vendor/fssm/lib/fssm/backends/polling.rb
sass-3.1.5 vendor/fssm/lib/fssm/backends/polling.rb
fssm-0.2.7 lib/fssm/backends/polling.rb
fssm-0.2.6.1 lib/fssm/backends/polling.rb
fssm-0.2.6 lib/fssm/backends/polling.rb
fssm-0.2.5 lib/fssm/backends/polling.rb