[Rake-devel] Rake 0.9.3.beta.2 with -j option

Jim Weirich jim.weirich at gmail.com
Mon Oct 22 19:04:47 UTC 2012


I've merge Michael Bishop's "-j"/thread pool pull request into the master branch and intend to include it in the next release.  I've push the current code base out as Rake 0.9.3.beta.2, so feel free to download it and give it a try.

I am especially interested in developers running on windows to give the -j option with multitasks a spin.

Here's a rakefile I used in playing with the -j option.  Try rake with different numbers on the -j option and see how it behaves.

#--Start Rakefile --
#!/usr/bin/ruby -wKU

require 'thread'

$m = Mutex.new

def out(*str)
  $m.synchronize do
    puts(*str)
  end
end

DELAY = 0.1

TASKS = ('a'..'z').map { |prefix| "#{prefix}_task" }

TASKS.each do |name|
  desc "#{name} prereq"
  subtasks = ('0'..'9').map { |suffix| "#{name}_sub#{suffix}" }
  subtasks.each do |name|
    task name do
      sleep DELAY
    end
  end
  multitask name => subtasks do
    sleep DELAY
  end
end

multitask :main => TASKS

task :default do
  t = Time.now
  Rake::Task[:main].invoke
  delta = Time.now - t
  out "#{delta} seconds have passed"
end
#--End Rakefile --


-- 
-- Jim Weirich
-- jim.weirich at gmail.com







More information about the Rake-devel mailing list