Sha256: 57033b70645344bdd444bc8d3f192e84854e91d8001369ce20484b9e805f178a

Contents?: true

Size: 594 Bytes

Versions: 39

Compression:

Stored size: 594 Bytes

Contents

require 'parallel'

module JsDuck

  # Wrapper around the parallel gem that falls back to simple
  # Array#map and Array#each when :in_processes => 0 specified.
  class ParallelWrap

    # Takes config object for parallel
    def initialize(cfg = {})
      @cfg = cfg
    end

    def each(arr, &block)
      if @cfg[:in_processes] == 0
        arr.each &block
      else
        Parallel.each(arr, @cfg, &block)
      end
    end

    def map(arr, &block)
      if @cfg[:in_processes] == 0
        arr.map &block
      else
        Parallel.map(arr, @cfg, &block)
      end
    end
  end

end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
jsduck-3.11.2 lib/jsduck/parallel_wrap.rb
jsduck-3.11.1 lib/jsduck/parallel_wrap.rb
jsduck-4.0.beta lib/jsduck/parallel_wrap.rb
jsduck-3.11.0 lib/jsduck/parallel_wrap.rb
jsduck-3.10.5 lib/jsduck/parallel_wrap.rb
jsduck-3.10.4 lib/jsduck/parallel_wrap.rb
jsduck-3.10.3 lib/jsduck/parallel_wrap.rb
jsduck-3.10.2 lib/jsduck/parallel_wrap.rb
jsduck-3.10.1 lib/jsduck/parallel_wrap.rb
jsduck-3.10.0 lib/jsduck/parallel_wrap.rb
jsduck-3.9.1 lib/jsduck/parallel_wrap.rb
jsduck-3.9.0 lib/jsduck/parallel_wrap.rb
jsduck-3.9.0.pre lib/jsduck/parallel_wrap.rb
jsduck-3.8.4 lib/jsduck/parallel_wrap.rb
jsduck-3.8.3 lib/jsduck/parallel_wrap.rb
jsduck-3.8.2 lib/jsduck/parallel_wrap.rb
jsduck-3.8.1 lib/jsduck/parallel_wrap.rb
jsduck-3.8.0 lib/jsduck/parallel_wrap.rb
jsduck-3.7.0 lib/jsduck/parallel_wrap.rb
jsduck-3.6.1 lib/jsduck/parallel_wrap.rb