class Listen::Adapter::Polling

Polling Adapter that works cross-platform and has no dependencies. This is the adapter that uses the most CPU processing power and has higher file IO than the other implementations.

Constants

DEFAULTS
OS_REGEXP

Private Instance Methods

_configure(_, &callback) click to toggle source
# File lib/listen/adapter/polling.rb, line 17
def _configure(_, &callback)
  @polling_callbacks ||= []
  @polling_callbacks << callback
end
_process_event(dir, _) click to toggle source
# File lib/listen/adapter/polling.rb, line 35
def _process_event(dir, _)
  _queue_change(:dir, dir, '.', recursive: true)
end
_run() click to toggle source
# File lib/listen/adapter/polling.rb, line 22
def _run
  loop do
    start = MonotonicTime.now
    @polling_callbacks.each do |callback|
      callback.call(nil)
      if (nap_time = options.latency - (MonotonicTime.now - start)) > 0
        # TODO: warn if nap_time is negative (polling too slow)
        sleep(nap_time)
      end
    end
  end
end