The RevScanner uses the Rev 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).
Start the Rev scanner loop. If the scanner is already running, this method will return without taking any action.
# File lib/directory_watcher/rev_scanner.rb, line 33 def start return if running? @timer = Timer.new self @thread = Thread.new { rev_loop = Thread.current._rev_loop @files.keys.each do |fn| if test ee, fn _watch_file fn next end @files.delete fn @events << ::DirectoryWatcher::Event.new(:removed, fn) end @timer.attach rev_loop rev_loop.run } end
Stop the Rev scanner loop. If the scanner is already stopped, this method will return without taking any action.
# File lib/directory_watcher/rev_scanner.rb, line 57 def stop return unless running? @timer.detach @timer = nil @watchers.each_value {|w| w.detach} @watchers.clear notify @thread._rev_loop.stop rescue nil @thread.kill # for some reason the rev loop is not returning after stopping @thread = nil end
Generated with the Darkfish Rdoc Generator 2.