From 86418dbc983688281647b39d36739de73c245501 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Sun, 23 Aug 2015 16:32:31 -0700 Subject: ever so slightly more responsible thread usage --- .../vendor/compact_index_client/lib/compact_index_client.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/bundler/vendor') diff --git a/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb b/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb index 52500c0657..6f8ec72a70 100644 --- a/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb +++ b/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb @@ -1,5 +1,5 @@ require "pathname" -require "set" +require "bundler/worker" class Bundler::CompactIndexClient require "bundler/vendor/compact_index_client/lib/compact_index_client/cache" @@ -27,9 +27,13 @@ class Bundler::CompactIndexClient versions end - def dependencies(names) - names.map {|n| Thread.new{ update_info(n) } }.each(&:join) - names.map do |name| + def dependencies(names, pool_size = 25) + update = -> (name, q) { update_info(name); name } + worker = Bundler::Worker.new(pool_size, update) + names.each {|name| worker.enq(name) } + + names.map do + name = worker.deq @cache.dependencies(name).map {|d| d.unshift(name) } end.flatten(1) end -- cgit v1.2.1