Sha256: de5353a12b845ac4dffaa362493c2e5ed2db69015e5366c53cd79eee734f987d

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

module Rake ; end

require 'rake/comp_tree/driver'

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
         
      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
        #
        parallel_tasks.each_pair { |task_name, task_args|
          task = self[task_name]
          children_names = task.prerequisites.map { |child|
            child.to_sym
          }
          driver.define(task_name.to_sym, *children_names) {
            task.execute(task_args)
          }
        }

        #
        # 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
        #
        driver.compute(root_name, :threads => num_threads, :fork => false)
      }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
drake-0.8.1.10.0.1 lib/rake/parallel.rb
drake-0.8.1.11.0.1 lib/rake/parallel.rb
drake-0.8.1.10.0 lib/rake/parallel.rb
drake-0.8.2.0.0.2 lib/rake/parallel.rb