Run each search_tap in a separate thread to speed things up.

Closes Homebrew/homebrew#14066.

Signed-off-by: Max Howell <mxcl@me.com>
This commit is contained in:
hazz 2012-08-08 22:25:04 +01:00 committed by Max Howell
parent f9751d63c4
commit 60bdb16a7c

View File

@ -31,12 +31,19 @@ module Homebrew extend self
if query
$found = search_results.length
# TODO parallelize!
puts_columns search_tap "josegonzalez", "php", rx
puts_columns search_tap "Homebrew", "versions", rx
puts_columns search_tap "Homebrew", "dupes", rx
puts_columns search_tap "Homebrew", "games", rx
puts_columns search_tap "Homebrew", "science", rx
threads = []
results = []
threads << Thread.new { search_tap "josegonzalez", "php", rx }
threads << Thread.new { search_tap "Homebrew", "versions", rx }
threads << Thread.new { search_tap "Homebrew", "dupes", rx }
threads << Thread.new { search_tap "Homebrew", "games", rx }
threads << Thread.new { search_tap "Homebrew", "science", rx }
threads.each do |t|
results << t.value
end
results.each { |r| puts_columns r }
if $found == 0 and not blacklisted? query
puts "No formula found for \"#{query}\". Searching open pull requests..."