class PArray

Constants

DEFAULT_CONCURRENCY
VERSION

Public Class Methods

new(arr, in_threads:) click to toggle source
# File lib/parray.rb, line 18
def initialize(arr, in_threads:)
  if !arr.respond_to?(:to_a)
    raise Error.new("#{arr} must respond to `#to_a`!")
  end
  @arr        = arr
  @in_threads = in_threads
end
parallelize(arr, in_threads: DEFAULT_CONCURRENCY) click to toggle source
# File lib/parray.rb, line 11
def parallelize(arr, in_threads: DEFAULT_CONCURRENCY)
  PArray.new(arr, in_threads: in_threads)
end

Public Instance Methods

each() { |*args| ... } click to toggle source
# File lib/parray.rb, line 30
def each(&block)
  Parallel.each(@arr.to_a, in_threads: @in_threads) { |*args| yield *args }
end
map() { |*args| ... } click to toggle source
# File lib/parray.rb, line 26
def map(&block)
  Parallel.map(@arr.to_a, in_threads: @in_threads) { |*args| yield *args }
end
to_a() click to toggle source
# File lib/parray.rb, line 34
def to_a
  @arr.to_a
end