Skip to content

Commit

Permalink
Add abort_on_exception to threaded_map
Browse files Browse the repository at this point in the history
  • Loading branch information
heaven authored and sferik committed Oct 20, 2012
1 parent 6228922 commit 15c9a7c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/twitter/core_ext/enumerable.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
module Enumerable

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

end

0 comments on commit 15c9a7c

Please sign in to comment.