Sha256: 3d0bb9af94ea73ecc4a66561a87385be384a3b4b72edd9df7c6c74ecd4190af1

Contents?: true

Size: 426 Bytes

Versions: 1

Compression:

Stored size: 426 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
    yield
  ensure
    Thread.abort_on_exception = initial_abort_on_exception
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

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