class Rake::Parallel::Driver
Attributes
Tasks collected during the dry-run phase.
Public Class Methods
Source
# File lib/rake/parallel.rb 27 def initialize 28 @tasks = Hash.new 29 @mutex = Mutex.new 30 end
Public Instance Methods
Source
# File lib/rake/parallel.rb 62 def compute(root_task, threads) 63 CompTree.build do |driver| 64 @tasks.each_pair do |task, (task_args, prereqs)| 65 needed_prereq_names = [] 66 67 prereqs.each do |prereq| 68 # if a prereq is not needed then it didn't get into @tasks 69 if @tasks.has_key? prereq 70 needed_prereq_names << prereq.name 71 end 72 end 73 74 # define a computation node which executes the task 75 driver.define(task.name, *needed_prereq_names) { 76 task.execute(task_args) 77 } 78 end 79 80 # punch it 81 driver.compute(root_task.name, threads) 82 end 83 end
Build and run the computation tree.
Called from Parallel::Driver#invoke
.
Source
# File lib/rake/parallel.rb 37 def invoke(threads, task, *task_args) 38 if @mutex.try_lock 39 begin 40 @tasks.clear 41 42 # dry run task collector 43 task.invoke_serial(*task_args) 44 45 if @tasks.has_key? task 46 # hand it off to comp_tree 47 compute(task, threads) 48 end 49 ensure 50 @mutex.unlock 51 end 52 else 53 raise InvokeInsideInvoke 54 end 55 end
Top-level parallel invocation.
Called from Task#invoke
(routed through Task#invoke_parallel).