Class DirectoryWatcher::EmScanner
In: lib/directory_watcher/em_scanner.rb
Parent: ::DirectoryWatcher::Scanner

The EmScanner uses the EventMachine reactor loop to monitor changes to files in the watched directory. This scanner is more efficient than the pure Ruby scanner because it relies on the operating system kernel notifictions instead of a periodic polling and stat of every file in the watched directory (the technique used by the Scanner class).

EventMachine cannot notify us when a file is added to the watched directory; therefore, added files are only picked up when we apply the glob pattern to the directory. This is done at the configured interval.

Notes:

 * Kqueue does not generate notifications when "touch" is used to update
   a file's timestamp. This applies to Mac and BSD systems.

 * New files are detected only when the watched directory is polled at the
   configured interval.

Methods

join   new   running?   start   stop  

Public Class methods

Create an EventMachine based scanner that will generate file events and pass those events (as an array) to the given block.

Public Instance methods

This is a no-op method for the EventMachine file scanner.

Returns true if the scanner is currently running. Returns false if this is not the case.

Start the EventMachine scanner. If the scanner has already been started this method will return without taking any action.

If the EventMachine reactor is not running, it will be started by this method.

Stop the EventMachine scanner. If the scanner is already stopped this method will return without taking any action.

The EventMachine reactor will not be stopped by this method. It is up to the user to stop the reactor using the EventMachine#stop_event_loop method.

[Validate]