Class: RenuoBinCheck::MasterThread
- Inherits:
-
Object
- Object
- RenuoBinCheck::MasterThread
- Defined in:
- lib/renuo_bin_check/master_thread.rb
Instance Attribute Summary collapse
-
#printer ⇒ Object
readonly
Returns the value of attribute printer.
-
#threads ⇒ Object
readonly
Returns the value of attribute threads.
Instance Method Summary collapse
- #add_thread(script_config) ⇒ Object
- #finalize ⇒ Object
-
#initialize(printer) ⇒ MasterThread
constructor
A new instance of MasterThread.
Constructor Details
#initialize(printer) ⇒ MasterThread
Returns a new instance of MasterThread.
7 8 9 10 11 |
# File 'lib/renuo_bin_check/master_thread.rb', line 7 def initialize(printer) @threads = [] @results = [] @printer = printer end |
Instance Attribute Details
#printer ⇒ Object (readonly)
Returns the value of attribute printer.
5 6 7 |
# File 'lib/renuo_bin_check/master_thread.rb', line 5 def printer @printer end |
#threads ⇒ Object (readonly)
Returns the value of attribute threads.
5 6 7 |
# File 'lib/renuo_bin_check/master_thread.rb', line 5 def threads @threads end |
Instance Method Details
#add_thread(script_config) ⇒ Object
13 14 15 16 17 18 |
# 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 ⇒ Object
20 21 22 23 24 25 26 27 28 |
# 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 |