Class: RailsParallel::Runner::Child
- Inherits:
-
Object
- Object
- RailsParallel::Runner::Child
- Includes:
- Forks
- Defined in:
- lib/rails_parallel/runner/child.rb
Instance Attribute Summary collapse
-
#last_suite ⇒ Object
readonly
Returns the value of attribute last_suite.
-
#last_time ⇒ Object
readonly
Returns the value of attribute last_time.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #close ⇒ Object
- #finish ⇒ Object
-
#initialize(number, schema, collector) ⇒ Child
constructor
A new instance of Child.
- #kill ⇒ Object
- #launch ⇒ Object
- #poll ⇒ Object
- #run_suite(name) ⇒ Object
Methods included from Forks
#before_exit, #check_status, #fork_and_run, #wait_any, #wait_for
Constructor Details
#initialize(number, schema, collector) ⇒ Child
Returns a new instance of Child.
11 12 13 14 15 16 17 |
# File 'lib/rails_parallel/runner/child.rb', line 11 def initialize(number, schema, collector) @number = number @schema = schema @collector = collector @buffer = '' @state = :waiting end |
Instance Attribute Details
#last_suite ⇒ Object (readonly)
Returns the value of attribute last_suite.
9 10 11 |
# File 'lib/rails_parallel/runner/child.rb', line 9 def last_suite @last_suite end |
#last_time ⇒ Object (readonly)
Returns the value of attribute last_time.
9 10 11 |
# File 'lib/rails_parallel/runner/child.rb', line 9 def last_time @last_time end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
9 10 11 |
# File 'lib/rails_parallel/runner/child.rb', line 9 def number @number end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
9 10 11 |
# File 'lib/rails_parallel/runner/child.rb', line 9 def pid @pid end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
9 10 11 |
# File 'lib/rails_parallel/runner/child.rb', line 9 def socket @socket end |
Instance Method Details
#close ⇒ Object
43 44 45 |
# File 'lib/rails_parallel/runner/child.rb', line 43 def close @socket.close end |
#finish ⇒ Object
39 40 41 |
# File 'lib/rails_parallel/runner/child.rb', line 39 def finish @socket << :finish end |
#kill ⇒ Object
47 48 49 50 |
# File 'lib/rails_parallel/runner/child.rb', line 47 def kill Process.kill('KILL', @pid) close rescue nil end |
#launch ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rails_parallel/runner/child.rb', line 19 def launch parent_socket, child_socket = ObjectSocket.pair @pid = fork_and_run do parent_socket.close @socket = child_socket main_loop end child_socket.close @socket = parent_socket @socket.nonblock = true end |
#poll ⇒ Object
56 57 58 59 60 |
# File 'lib/rails_parallel/runner/child.rb', line 56 def poll output = [] @socket.each_object { |obj| output << obj } output end |
#run_suite(name) ⇒ Object
33 34 35 36 37 |
# File 'lib/rails_parallel/runner/child.rb', line 33 def run_suite(name) @last_suite = name @last_time = Time.now @socket << name end |