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.
# File lib/listen/adapter/polling.rb, line 15 def _configure(_, &callback) @polling_callbacks ||= [] @polling_callbacks << callback end
# File lib/listen/adapter/polling.rb, line 31 def _process_event(dir, _) _queue_change(:dir, dir, '.', recursive: true) end
# File lib/listen/adapter/polling.rb, line 20 def _run loop do start = Time.now.to_f @polling_callbacks.each do |callback| callback.call(nil) nap_time = options.latency - (Time.now.to_f - start) sleep(nap_time) if nap_time > 0 end end end