Class: Bio::MAF::ForkRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/maf/jobs.rb

Instance Method Summary collapse

Constructor Details

#initialize(n_parallel) ⇒ ForkRunner

Returns a new instance of ForkRunner.



18
19
20
21
22
# File 'lib/bio/maf/jobs.rb', line 18

def initialize(n_parallel)
  @n_parallel = n_parallel
  @jobs = []
  @kids = Set.new
end

Instance Method Details

#add(&proc) ⇒ Object



24
25
26
# File 'lib/bio/maf/jobs.rb', line 24

def add(&proc)
  @jobs << proc
end

#runObject



28
29
30
31
32
33
34
35
# File 'lib/bio/maf/jobs.rb', line 28

def run
  until @jobs.empty? && @kids.empty?
    while can_start?
      start_job
    end
    await
  end
end