Class: Parallel::Worker

### Home Classes Methods

### In Files

- lib/parallel.rb

### Parent

Object

### Methods

- ::new
- #close_pipes
- #wait
- #work

### Class/Module Index

Quicksearch

- Parallel
- Parallel::Break
- Parallel::DeadWorker
- Parallel::ExceptionWrapper
- Parallel::JobFactory
- Parallel::Kill
- Parallel::ProcessorCount
- Parallel::UserInterruptHandler
- Parallel::Worker

No matching classes.

# Parallel::Worker

### Attributes

pid[R]
read[R]
thread[RW]
write[R]

### Public Class Methods

new(read, write, pid) click to toggle source

    # File lib/parallel.rb, line 34
    def initialize(read, write, pid)
      @read, @write, @pid = read, write, pid
    end

### Public Instance Methods

close_pipes() click to toggle source

    # File lib/parallel.rb, line 38
    def close_pipes
      read.close
      write.close
    end

wait() click to toggle source

    # File lib/parallel.rb, line 43
    def wait
      Process.wait(pid)
    rescue Interrupt
      # process died
    end

work(data) click to toggle source

    # File lib/parallel.rb, line 49
    def work(data)
      begin
        Marshal.dump(data, write)
      rescue Errno::EPIPE
        raise DeadWorker
      end

      result = begin
        Marshal.load(read)
      rescue EOFError
        raise DeadWorker
      end
      raise result.exception if ExceptionWrapper === result
      result
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.