The CoolioScanner uses the Coolio 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 Coolio scanner loop. If the scanner is already running, this method will return without taking any action.
# File lib/directory_watcher/coolio_scanner.rb, line 32 def start return if running? @timer = Timer.new self @thread = Thread.new { coolio_loop = Thread.current._coolio_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(coolio_loop) coolio_loop.run } end
Stop the Coolio scanner loop. If the scanner is already stopped, this method will return without taking any action.
# File lib/directory_watcher/coolio_scanner.rb, line 56 def stop return unless running? @timer.detach @timer = nil @watchers.each_value {|w| w.detach} @watchers.clear notify @thread._coolio_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.