class Rake::Jobs

Public Class Methods

new(jobs, max, &block) click to toggle source
# File lib/cxxproject/ext/rake.rb, line 80
def initialize(jobs, max, &block)
  nr_of_threads = [max, jobs.length].min
  @jobs = jobs
  @threads = []
  nr_of_threads.times do
    @threads << Thread.new do
      block.call(self)
    end
  end
end

Public Instance Methods

get_next_or_nil() click to toggle source
# File lib/cxxproject/ext/rake.rb, line 91
def get_next_or_nil
  the_next = nil
  mutex.synchronize {
    the_next = @jobs.shift
  }
  the_next
end
join() click to toggle source
# File lib/cxxproject/ext/rake.rb, line 98
def join
  @threads.each{|t| while not t.join(2) do end}
end
mutex() click to toggle source
# File lib/cxxproject/ext/rake.rb, line 101
def mutex
  @mutex ||= Mutex.new
end