Sha256: fa948085d7ad381b9f2181fa25a75eadda4e2228dc3be068687bf5e3983c15eb

Contents?: true

Size: 1.33 KB

Versions: 8

Compression:

Stored size: 1.33 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, cache|
          task = self[task_name]
          task_args, prereqs = cache
          children_names = prereqs.map { |child|
            child.name.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

8 entries across 8 versions & 1 rubygems

Version Path
drake-0.8.2.1.0.4 lib/rake/parallel.rb
drake-0.8.2.1.0.10 lib/rake/parallel.rb
drake-0.8.2.1.0.11 lib/rake/parallel.rb
drake-0.8.2.1.0.12 lib/rake/parallel.rb
drake-0.8.2.1.0.5 lib/rake/parallel.rb
drake-0.8.2.1.0.6 lib/rake/parallel.rb
drake-0.8.2.1.0.7 lib/rake/parallel.rb
drake-0.8.2.1.0.9 lib/rake/parallel.rb