Class: Listen::Adapters::BSD
- Inherits:
-
Listen::Adapter
- Object
- Listen::Adapter
- Listen::Adapters::BSD
- Extended by:
- DependencyManager
- Defined in:
- lib/listen/adapters/bsd.rb
Overview
Listener implementation for BSD’s ‘kqueue`.
Constant Summary collapse
- EVENTS =
Watched kqueue events
[ :delete, :write, :extend, :attrib, :link, :rename, :revoke ]
Constants included from DependencyManager
DependencyManager::BUNDLER_DECLARE_GEM, DependencyManager::GEM_INSTALL_COMMAND, DependencyManager::GEM_LOAD_MESSAGE
Constants inherited from Listen::Adapter
Listen::Adapter::DEFAULT_LATENCY, Listen::Adapter::MISSING_DEPENDENCY_MESSAGE, Listen::Adapter::POLLING_FALLBACK_MESSAGE
Instance Attribute Summary
Attributes inherited from Listen::Adapter
#directories, #latency, #paused
Class Method Summary collapse
-
.usable? ⇒ Boolean
Checks if the adapter is usable on the current OS.
Instance Method Summary collapse
-
#initialize(directories, options = {}, &callback) ⇒ BSD
constructor
Initializes the Adapter.
-
#start(blocking = true) ⇒ Object
Starts the adapter.
-
#stop ⇒ Object
Stops the adapter.
Methods included from DependencyManager
add_loaded, already_loaded?, clear_loaded, dependencies_loaded?, dependency, extended, load_depenencies
Methods inherited from Listen::Adapter
#report_changes, select_and_initialize, #started?, usable_and_works?, #wait_for_callback, #wait_for_changes, works?
Constructor Details
#initialize(directories, options = {}, &callback) ⇒ BSD
Initializes the Adapter. See Listen::Adapter#initialize for more info.
22 23 24 25 |
# File 'lib/listen/adapters/bsd.rb', line 22 def initialize(directories, = {}, &callback) super @kqueue = init_kqueue end |
Class Method Details
.usable? ⇒ Boolean
Checks if the adapter is usable on the current OS.
65 66 67 68 |
# File 'lib/listen/adapters/bsd.rb', line 65 def self.usable? return false unless RbConfig::CONFIG['target_os'] =~ /freebsd/i super end |
Instance Method Details
#start(blocking = true) ⇒ Object
Starts the adapter.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/listen/adapters/bsd.rb', line 31 def start(blocking = true) @mutex.synchronize do return if @stop == false super end @kqueue_thread = Thread.new do until @stop @kqueue.poll sleep(@latency) end end @poll_thread = Thread.new { poll_changed_dirs } if @report_changes @kqueue_thread.join if blocking end |
#stop ⇒ Object
Stops the adapter.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/listen/adapters/bsd.rb', line 50 def stop @mutex.synchronize do return if @stop == true super end @kqueue.stop Thread.kill(@kqueue_thread) if @kqueue_thread @poll_thread.join if @poll_thread end |