Class: JCukeForker::TaskManager

Inherits:
AbstractListener show all
Defined in:
lib/jcukeforker/task_manager.rb

Instance Method Summary collapse

Methods inherited from AbstractListener

#on_run_finished, #on_run_interrupted, #on_run_starting, #on_task_starting, #on_worker_waiting, #update

Constructor Details

#initialize(features, opts = {}) ⇒ TaskManager

Returns a new instance of TaskManager.



5
6
7
8
9
10
# File 'lib/jcukeforker/task_manager.rb', line 5

def initialize(features, opts={})
  @features = features
  @opts = opts
  @worker_sockets = {}
  @failures = false
end

Instance Method Details

#closeObject



27
28
29
# File 'lib/jcukeforker/task_manager.rb', line 27

def close
  @worker_sockets.each {|k, v| v.close}
end

#has_failures?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/jcukeforker/task_manager.rb', line 31

def has_failures?
  @failures
end

#on_task_finished(worker_path, feature, status) ⇒ Object



17
18
19
20
# File 'lib/jcukeforker/task_manager.rb', line 17

def on_task_finished(worker_path, feature, status)
  @failures = @failures || !status
  pop_task worker_path
end

#on_worker_dead(worker_path) ⇒ Object



22
23
24
25
# File 'lib/jcukeforker/task_manager.rb', line 22

def on_worker_dead(worker_path)
 socket = @worker_sockets.delete worker_path
 socket.close
end

#on_worker_register(worker_path) ⇒ Object



12
13
14
15
# File 'lib/jcukeforker/task_manager.rb', line 12

def on_worker_register(worker_path)
  @worker_sockets[worker_path] = UNIXSocket.open worker_path
  pop_task worker_path
end