Class: Gem::Dependent::Parallel::Worker
- Inherits:
-
Object
- Object
- Gem::Dependent::Parallel::Worker
- Defined in:
- lib/rubygems/dependent/parallel.rb
Instance Attribute Summary collapse
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#read ⇒ Object
readonly
Returns the value of attribute read.
-
#write ⇒ Object
readonly
Returns the value of attribute write.
Instance Method Summary collapse
- #close_pipes ⇒ Object
-
#initialize(read, write, pid) ⇒ Worker
constructor
A new instance of Worker.
- #wait ⇒ Object
- #work(index) ⇒ Object
Constructor Details
#initialize(read, write, pid) ⇒ Worker
Returns a new instance of Worker.
34 35 36 |
# File 'lib/rubygems/dependent/parallel.rb', line 34 def initialize(read, write, pid) @read, @write, @pid = read, write, pid end |
Instance Attribute Details
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
33 34 35 |
# File 'lib/rubygems/dependent/parallel.rb', line 33 def pid @pid end |
#read ⇒ Object (readonly)
Returns the value of attribute read.
33 34 35 |
# File 'lib/rubygems/dependent/parallel.rb', line 33 def read @read end |
#write ⇒ Object (readonly)
Returns the value of attribute write.
33 34 35 |
# File 'lib/rubygems/dependent/parallel.rb', line 33 def write @write end |
Instance Method Details
#close_pipes ⇒ Object
38 39 40 41 |
# File 'lib/rubygems/dependent/parallel.rb', line 38 def close_pipes read.close write.close end |
#wait ⇒ Object
43 44 45 46 47 |
# File 'lib/rubygems/dependent/parallel.rb', line 43 def wait Process.wait(pid) rescue Interrupt # process died end |
#work(index) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rubygems/dependent/parallel.rb', line 49 def work(index) begin Marshal.dump(index, write) rescue Errno::EPIPE raise DeadWorker end begin Marshal.load(read) rescue EOFError raise Parallel::DeadWorker end end |