Class: JsDuck::Util::Parallel
- Inherits:
-
Object
- Object
- JsDuck::Util::Parallel
- Defined in:
- lib/jsduck/util/parallel.rb
Overview
Wrapper around the parallel gem that falls back to simple Array#map and Array#each when :in_processes => 0 specified.
Constant Summary collapse
- @@in_processes =
nil
Class Method Summary collapse
- .each(arr, &block) ⇒ Object
-
.in_processes=(n) ⇒ Object
Sets globally the nr of processes to use.
- .map(arr, &block) ⇒ Object
Class Method Details
.each(arr, &block) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/jsduck/util/parallel.rb', line 16 def self.each(arr, &block) if @@in_processes == 0 arr.each &block else ::Parallel.each(arr, {:in_processes => @@in_processes}, &block) end end |
.in_processes=(n) ⇒ Object
Sets globally the nr of processes to use.
12 13 14 |
# File 'lib/jsduck/util/parallel.rb', line 12 def self.in_processes=(n) @@in_processes = n end |
.map(arr, &block) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/jsduck/util/parallel.rb', line 24 def self.map(arr, &block) if @@in_processes == 0 arr.map &block else ::Parallel.map(arr, {:in_processes => @@in_processes}, &block) end end |