Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

optimized construction of computation tree

  • Loading branch information...
commit 88f13dc449dea7acdcd3551380d466dc11c8d7ba 1 parent 676c30c
James M. Lawrence quix authored
Showing with 24 additions and 29 deletions.
  1. +1 −1  lib/rake.rb
  2. +23 −28 lib/rake/parallel.rb
2  lib/rake.rb
View
@@ -582,7 +582,7 @@ def invoke(*args)
application.parallel_tasks.clear
application.parallel_parent_flags.clear
base_invoke(*args)
- application.invoke_parallel_tasks
+ application.invoke_parallel(self.name)
}
end
end
51 lib/rake/parallel.rb
View
@@ -5,25 +5,10 @@ module Rake ; end
module Rake
module TaskManager
- # :nodoc:
- def invoke_parallel_tasks
- parent_names = parallel_tasks.keys.map { |name|
- name.to_sym
- }
-
- root_name = "computation_root__#{Process.pid}__#{rand}".to_sym
-
+ def invoke_parallel(root_task_name) # :nodoc:
CompTree::Driver.new(:discard_result => true) { |driver|
#
- # Define the root computation node.
- #
- # Top-level tasks are immediate children of the root.
- #
- driver.define(root_name, *parent_names) {
- }
-
- #
- # build the rest of the computation tree from task prereqs
+ # Build the computation tree from task prereqs.
#
parallel_tasks.each_pair { |task_name, cache|
task = self[task_name]
@@ -36,19 +21,29 @@ def invoke_parallel_tasks
}
}
+ root_node = driver.nodes[root_task_name.to_sym]
+
#
- # Mark computation nodes without a function as computed.
- #
- driver.nodes[root_name].each_downward { |node|
- unless node.function
- node.result = true
- end
- }
-
- #
- # launch the computation
+ # If there were nothing to do, there would be no root node.
#
- driver.compute(root_name, :threads => num_threads, :fork => false)
+ if root_node
+ #
+ # Mark computation nodes without a function as computed.
+ #
+ root_node.each_downward { |node|
+ unless node.function
+ node.result = true
+ end
+ }
+
+ #
+ # Launch the computation.
+ #
+ driver.compute(
+ root_node.name,
+ :threads => num_threads,
+ :fork => false)
+ end
}
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.