Class: DirectoryWatcher::CoolioScanner

### Home Classes Methods

### In Files

- lib/directory_watcher/coolio_scanner.rb

### Parent

DirectoryWatcher::EventableScanner

### Namespace

- CLASS DirectoryWatcher::CoolioScanner::ScanTimer
- CLASS DirectoryWatcher::CoolioScanner::Watcher

### Methods

- ::new
- #event_loop
- #start_loop_with_attached_scan_timer
- #stop_loop

### Files

- History.txt
- README.txt

### Class/Module Index

Quicksearch

- DirectoryWatcher
- DirectoryWatcher::Collector
- DirectoryWatcher::Configuration
- DirectoryWatcher::CoolioScanner
- DirectoryWatcher::EmScanner
- DirectoryWatcher::Event
- DirectoryWatcher::EventableScanner
- DirectoryWatcher::FileStat
- DirectoryWatcher::Logable
- DirectoryWatcher::Notifier
- DirectoryWatcher::NullLogger
- DirectoryWatcher::Paths
- DirectoryWatcher::RevScanner
- DirectoryWatcher::Scan
- DirectoryWatcher::ScanAndQueue
- DirectoryWatcher::Scanner
- DirectoryWatcher::Threaded
- DirectoryWatcher::Version
- Object

No matching classes.

# DirectoryWatcher::CoolioScanner

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 notifications instead of a periodic polling and stat of every file in the watched directory (the technique used by the Scanner class).

Coolio 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.

### Public Class Methods

new( config ) click to toggle source

    # File lib/directory_watcher/coolio_scanner.rb, line 24
    def initialize( config )
      super(config)
    end

### Public Instance Methods

event_loop() click to toggle source

Return the cool.io loop object.

This is used during the startup, shutdown process and for the Watcher to attach and detach from the event loop

    # File lib/directory_watcher/coolio_scanner.rb, line 56
    def event_loop
      if @loop_thread then
        @loop_thread._coolio_loop
      else
        Thread.current._coolio_loop
      end
    end

start_loop_with_attached_scan_timer() click to toggle source

Called by EventablScanner#start to start the loop up and attach the periodic timer that will poll the globs for new files.

    # File lib/directory_watcher/coolio_scanner.rb, line 31
    def start_loop_with_attached_scan_timer
      return if @loop_thread
      @timer = ScanTimer.new( self )
      @loop_thread = Thread.new {
        @timer.attach(event_loop)
        event_loop.run
      }
    end

stop_loop() click to toggle source

Called by EventableScanner#stop to stop the loop as part of the shutdown process.

    # File lib/directory_watcher/coolio_scanner.rb, line 43
    def stop_loop
      if @loop_thread then
        event_loop.stop rescue nil
        @loop_thread.kill
        @loop_thread = nil
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.