Class: Listen::Adapter::Polling
- Defined in:
- lib/listen/adapter/polling.rb
Overview
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.
Constant Summary collapse
- OS_REGEXP =
match any
//
- DEFAULT_POLLING_LATENCY =
1.0
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #_latency ⇒ Object private
- #_run ⇒ Object private
Methods inherited from Base
#_configure, #_directories, #_log, #_notify_change, #initialize, local_fs?, #start, usable?
Constructor Details
This class inherits a constructor from Listen::Adapter::Base
Instance Method Details
#_latency ⇒ Object (private)
15 16 17 |
# File 'lib/listen/adapter/polling.rb', line 15 def _latency listener.[:latency] || DEFAULT_POLLING_LATENCY end |
#_run ⇒ Object (private)
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/listen/adapter/polling.rb', line 19 def _run loop do start = Time.now.to_f _directories.each do |path| _notify_change(:dir, path, recursive: true) nap_time = _latency - (Time.now.to_f - start) sleep(nap_time) if nap_time > 0 end end end |