Class: Open4::ThreadEnsemble

### Home Classes Methods

### In Files

- lib/open4.rb

### Parent

Object

### Methods

- ::new
- #add_thread
- #all_done
- #killall
- #run

### Class/Module Index

Quicksearch

- Open4
- Open4::Error
- Open4::SpawnError
- Open4::ThreadEnsemble
- Object

No matching classes.

# Open4::ThreadEnsemble

### Attributes

threads[R]

### Public Class Methods

new(cid) click to toggle source

    # File lib/open4.rb, line 159
    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.rb, line 164
    def add_thread *a, &b
      @running ? raise : (@argv << [a, b])
    end

all_done() click to toggle source

    # File lib/open4.rb, line 205
    def all_done
      @threads.size.times{ @done.pop }
    end

killall() click to toggle source

take down process more nicely

    # File lib/open4.rb, line 171
    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.rb, line 181
    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.