Parent

Open4::ThreadEnsemble

Attributes

threads[R]

Public Class Methods

new(cid) click to toggle source
# File lib/open4-vendor.rb, line 108
def initialize cid
  @cid, @threads, @argv, @done, @running = cid, [], [], Queue.new, false
  @killed = false
end

Public Instance Methods

add_thread(*a, &b) click to toggle source
# File lib/open4-vendor.rb, line 113
def add_thread *a, &b
  @running ? raise : (@argv << [a, b])
end
all_done() click to toggle source
# File lib/open4-vendor.rb, line 154
def all_done
  @threads.size.times{ @done.pop }
end
killall() click to toggle source

take down process more nicely

# File lib/open4-vendor.rb, line 120
def killall
  c = Thread.critical
  return nil if @killed
  Thread.critical = true
  (@threads - [Thread.current]).each{|t| t.kill rescue nil}
  @killed = true
ensure
  Thread.critical = c
end
run() click to toggle source
# File lib/open4-vendor.rb, line 130
def run
  @running = true

  begin
    @argv.each do |a, b|
      @threads << Thread.new(*a) do |*a|
        begin
          b[*a]
        ensure
          killall rescue nil if $!
          @done.push Thread.current
        end
      end
    end
  rescue
    killall
    raise
  ensure
    all_done
  end

  @threads.map{|t| t.value}
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.