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.
Create an EventMachine based scanner that will generate file events and pass those events (as an array) to the given block.