class Rake::Parallel::Driver
Attributes
tasks[R]
Tasks collected during the dry-run phase.
Public Class Methods
new()
click to toggle source
# File lib/rake/parallel.rb, line 27 def initialize @tasks = Hash.new @mutex = Mutex.new end
Public Instance Methods
compute(root_task, threads)
click to toggle source
Build and run the computation tree.
Called from #invoke.
# File lib/rake/parallel.rb, line 62 def compute(root_task, threads) CompTree.build do |driver| @tasks.each_pair do |task, (task_args, prereqs)| needed_prereq_names = [] prereqs.each do |prereq| # if a prereq is not needed then it didn't get into @tasks if @tasks.has_key? prereq needed_prereq_names << prereq.name end end # define a computation node which executes the task driver.define(task.name, *needed_prereq_names) { task.execute(task_args) } end # punch it driver.compute(root_task.name, threads) end end
invoke(threads, task, *task_args)
click to toggle source
Top-level parallel invocation.
Called from Rake::Task#invoke (routed through Task#invoke_parallel).
# File lib/rake/parallel.rb, line 37 def invoke(threads, task, *task_args) if @mutex.try_lock begin @tasks.clear # dry run task collector task.invoke_serial(*task_args) if @tasks.has_key? task # hand it off to comp_tree compute(task, threads) end ensure @mutex.unlock end else raise InvokeInsideInvoke end end