class RenuoBinCheck::MasterThread

Attributes

printer[R]
threads[R]

Public Class Methods

new(printer) click to toggle source
# File lib/renuo_bin_check/master_thread.rb, line 7
def initialize(printer)
  @threads = []
  @results = []
  @printer = printer
end

Public Instance Methods

add_thread(script_config) click to toggle source
# File lib/renuo_bin_check/master_thread.rb, line 13
def add_thread(script_config)
  threads << Thread.new do
    servant = ServantThread.new(script_config)
    Thread.current[:result] = servant.run
  end
end
finalize() click to toggle source
# File lib/renuo_bin_check/master_thread.rb, line 20
def finalize
  waiter = ThreadsWait.new(threads)
  until waiter.empty?
    result = waiter.next_wait[:result]
    @results << result
    exit_with_error(result) if result.exit_code == 1
  end
  exit_with_success
end

Private Instance Methods

exit_with_error(result) click to toggle source
# File lib/renuo_bin_check/master_thread.rb, line 32
def exit_with_error(result)
  @printer.print_error_output(result)
  exit 1
end
exit_with_success() click to toggle source
# File lib/renuo_bin_check/master_thread.rb, line 37
def exit_with_success
  @printer.print_standard_output(@results)
  exit 0
end