Class: Listen::Adapters::Polling
- Inherits:
-
Listen::Adapter
- Object
- Listen::Adapter
- Listen::Adapters::Polling
- Defined in:
- lib/listen/adapters/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 that the other implementations.
Constant Summary
Constants inherited from Listen::Adapter
Listen::Adapter::DEFAULT_LATENCY, Listen::Adapter::POLLING_FALLBACK_MESSAGE
Instance Attribute Summary
Attributes inherited from Listen::Adapter
#directories, #latency, #paused
Instance Method Summary collapse
-
#initialize(directories, options = {}, &callback) ⇒ Polling
constructor
Initialize the Adapter.
-
#start(blocking = true) ⇒ Object
Start the adapter.
-
#stop ⇒ Object
Stop the adapter.
Methods inherited from Listen::Adapter
select_and_initialize, #started?, usable_and_works?, #wait_for_callback, works?
Constructor Details
#initialize(directories, options = {}, &callback) ⇒ Polling
Initialize the Adapter. See Listen::Adapter#initialize for more info.
16 17 18 19 |
# File 'lib/listen/adapters/polling.rb', line 16 def initialize(directories, = {}, &callback) @latency ||= DEFAULT_POLLING_LATENCY super end |
Instance Method Details
#start(blocking = true) ⇒ Object
Start the adapter.
25 26 27 28 29 30 31 32 33 |
# File 'lib/listen/adapters/polling.rb', line 25 def start(blocking = true) @mutex.synchronize do return if @stop == false super end @poll_thread = Thread.new { poll } @poll_thread.join if blocking end |
#stop ⇒ Object
Stop the adapter.
37 38 39 40 41 42 43 44 |
# File 'lib/listen/adapters/polling.rb', line 37 def stop @mutex.synchronize do return if @stop == true super end @poll_thread.join end |