class JsDuck::Util::Parallel

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

Public Class Methods

configure(opts) click to toggle source

Configures the logger to use as many processes as set in command line options. When in Windows, turns the parallel processing off by default.

# File lib/jsduck/util/parallel.rb, line 15
def self.configure(opts)
  @@in_processes = 0 if Util::OS::windows?
  @@in_processes = opts.processes if opts.processes
end
each(arr, &block) click to toggle source
# File lib/jsduck/util/parallel.rb, line 20
def self.each(arr, &block)
  if @@in_processes == 0
    arr.each &block
  else
    ::Parallel.each(arr, {:in_processes => @@in_processes}, &block)
  end
end
map(arr, &block) click to toggle source
# File lib/jsduck/util/parallel.rb, line 28
def self.map(arr, &block)
  if @@in_processes == 0
    arr.map &block
  else
    ::Parallel.map(arr, {:in_processes => @@in_processes}, &block)
  end
end