Sha256: 43b8982f5b0c427af32b7561d63e55881c51afddbd3cdfe5588513ba4084eb71

Contents?: true

Size: 510 Bytes

Versions: 2

Compression:

Stored size: 510 Bytes

Contents

require 'pork/mode/shuffled'

module Pork
  class Parallel < Struct.new(:isolator)
    def cores
      8
    end

    def execute stat=Stat.new, paths=isolator.all_paths
      executor = Shuffled.new(isolator)
      stat.prepare(paths)
      paths.shuffle.each_slice(cores).map do |paths_slice|
        Thread.new do
          executor.execute(
            Stat.new(stat.reporter, stat.protected_exceptions),
            paths_slice)
        end
      end.map(&:value).inject(stat, &:merge)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pork-2.1.0 lib/pork/mode/parallel.rb
pork-2.0.0 lib/pork/mode/parallel.rb