Sha256: 8f1c08aaec45a0946eff3b812aade0f1746cec9ab4f6f932441686ca1208029c

Contents?: true

Size: 396 Bytes

Versions: 7

Compression:

Stored size: 396 Bytes

Contents

# frozen_string_literal: true

module Mcoin
  # :nodoc:
  class Parallel
    class << self
      def map(array, method)
        array.map do |item|
          Thread.new { item.send(method) }
        end.map(&:join).map(&:value)
      end

      def async(array, method, &block)
        array.each do |item|
          Thread.new { yield item.send(method) }
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mcoin-0.6.1 lib/mcoin/parallel.rb
mcoin-0.6.0 lib/mcoin/parallel.rb
mcoin-0.5.2 lib/mcoin/parallel.rb
mcoin-0.5.1 lib/mcoin/parallel.rb
mcoin-0.5.0 lib/mcoin/parallel.rb
mcoin-0.4.0 lib/mcoin/parallel.rb
mcoin-0.3.0 lib/mcoin/parallel.rb