Class: DirectoryWatcher::RevScanner
- Inherits:
-
EventableScanner
- Object
- EventableScanner
- DirectoryWatcher::RevScanner
- Defined in:
- lib/directory_watcher/rev_scanner.rb
Overview
Deprecated:
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 notifications instead of a periodic polling and stat of every file in the watched directory (the technique used by the Scanner class).
The RevScanner is essentially the exact same as the CoolioScanner with class names changed and using _rev_loop instead of _coolio_loop. Unfortunately the RevScanner cannot be a sub class of CoolioScanner because of C-extension reasons between the rev and coolio gems
Rev 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.
Defined Under Namespace
Instance Attribute Summary
Attributes inherited from EventableScanner
#iterations, #maximum_iterations, #watchers
Instance Method Summary collapse
-
#event_loop ⇒ Object
Return the rev loop object.
-
#initialize(glob, interval, collection_queue) ⇒ RevScanner
constructor
call-seq: RevScanner.new( glob, interval, collection_queue ).
-
#start_loop_with_attached_scan_timer ⇒ Object
Called by EventablScanner#start to start the loop up and attach the periodic timer that will poll the globs for new files.
-
#stop_loop ⇒ Object
Called by EventableScanner#stop to stop the loop as part of the shutdown process.
Methods inherited from EventableScanner
#collection_queue, #finished_iterations?, #interval, #join, #on_modified, #on_removed, #on_scan, #pause, #paused?, #resume, #run, #running?, #start, #stop
Methods included from Logable
Constructor Details
#initialize(glob, interval, collection_queue) ⇒ RevScanner
call-seq:
RevScanner.new( glob, interval, collection_queue )
31 32 33 |
# File 'lib/directory_watcher/rev_scanner.rb', line 31 def initialize( glob, interval, collection_queue ) super(glob, interval, collection_queue) end |
Instance Method Details
#event_loop ⇒ Object
Return the rev loop object
This is used during the startup, shutdown process and for the Watcher to attach and detach from the event loop
63 64 65 66 67 68 69 |
# File 'lib/directory_watcher/rev_scanner.rb', line 63 def event_loop if @loop_thread then @loop_thread._rev_loop else Thread.current._rev_loop end end |
#start_loop_with_attached_scan_timer ⇒ Object
Called by EventablScanner#start to start the loop up and attach the periodic timer that will poll the globs for new files.
38 39 40 41 42 43 44 45 |
# File 'lib/directory_watcher/rev_scanner.rb', line 38 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 ⇒ Object
Called by EventableScanner#stop to stop the loop as part of the shutdown process.
50 51 52 53 54 55 56 |
# File 'lib/directory_watcher/rev_scanner.rb', line 50 def stop_loop if @loop_thread then event_loop.stop rescue nil @loop_thread.kill @loop_thread = nil end end |