Class: DirectoryWatcher::EmScanner

Inherits:
EventableScanner show all
Defined in:
lib/directory_watcher/em_scanner.rb

Defined Under Namespace

Classes: ScanTimer, Watcher

Instance Attribute Summary

Attributes inherited from EventableScanner

#iterations, #maximum_iterations, #watchers

Instance Method Summary collapse

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

default_logger, #logger

Constructor Details

#initialize(config) ⇒ EmScanner

Returns a new instance of EmScanner.


40
41
42
# File 'lib/directory_watcher/em_scanner.rb', line 40

def initialize( config )
  super(config)
end

Instance Method Details

#start_loop_with_attached_scan_timerObject


47
48
49
50
51
52
53
54
55
# File 'lib/directory_watcher/em_scanner.rb', line 47

def start_loop_with_attached_scan_timer
  return if @loop_thread
  unless EventMachine.reactor_running?
    @loop_thread = Thread.new {EventMachine.run}
    Thread.pass until EventMachine.reactor_running?
  end

  @timer = ScanTimer.new(self)
end

#stop_loopObject

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


60
61
62
63
64
65
66
67
68
# File 'lib/directory_watcher/em_scanner.rb', line 60

def stop_loop
  if @loop_thread then
    EventMachine.next_tick do
      EventMachine.stop_event_loop
    end
    @loop_thread.kill
    @loop_thread = nil
  end
end