Sha256: 7c4b5e95b96f7593e2f8c79f7813b967ac345c20ad94ad21edf859ad4fbad0e7

Contents?: true

Size: 435 Bytes

Versions: 1

Compression:

Stored size: 435 Bytes

Contents

module Enumerable

  def threaded_map
    abort_on_exception do
      threads = []
      each do |object|
        threads << Thread.new { yield object }
      end
      threads.map(&:value)
    end
  end

private

  def abort_on_exception
    initial_abort_on_exception = Thread.abort_on_exception
    Thread.abort_on_exception ||= true
    value = yield
    Thread.abort_on_exception = initial_abort_on_exception
    value
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twitter-4.3.0 lib/twitter/core_ext/enumerable.rb