Class: Test::Unit::TestSuiteProcessRunner::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/test/unit/test-suite-process-runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pid, main_to_worker_output, worker_to_main_input) ⇒ Worker

Returns a new instance of Worker.



23
24
25
26
27
# File 'lib/test/unit/test-suite-process-runner.rb', line 23

def initialize(pid, main_to_worker_output, worker_to_main_input)
  @pid = pid
  @main_to_worker_output = main_to_worker_output
  @worker_to_main_input = worker_to_main_input
end

Instance Attribute Details

#main_to_worker_outputObject (readonly)

Returns the value of attribute main_to_worker_output.



22
23
24
# File 'lib/test/unit/test-suite-process-runner.rb', line 22

def main_to_worker_output
  @main_to_worker_output
end

#worker_to_main_inputObject (readonly)

Returns the value of attribute worker_to_main_input.



22
23
24
# File 'lib/test/unit/test-suite-process-runner.rb', line 22

def worker_to_main_input
  @worker_to_main_input
end

Instance Method Details

#receiveObject



29
30
31
# File 'lib/test/unit/test-suite-process-runner.rb', line 29

def receive
  Marshal.load(@worker_to_main_input)
end

#send(data) ⇒ Object



33
34
35
36
# File 'lib/test/unit/test-suite-process-runner.rb', line 33

def send(data)
  Marshal.dump(data, @main_to_worker_output)
  @main_to_worker_output.flush
end

#waitObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/test/unit/test-suite-process-runner.rb', line 38

def wait
  begin
    Process.waitpid(@pid)
  ensure
    begin
      @main_to_worker_output.close
    ensure
      @worker_to_main_input.close
    end
  end
end