Skip to content

Instantly share code, notes, and snippets.

@tarcieri
Created May 10, 2011 01:48
Show Gist options
  • Save tarcieri/963782 to your computer and use it in GitHub Desktop.
Save tarcieri/963782 to your computer and use it in GitHub Desktop.
Simple parallel map using threads
module Enumerable
def pmap
threads = map do |elem|
Thread.new { yield elem }
end
threads.map { |thread| thread.join.value }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment