diff options
author | Patrick Metcalfe <git@patrickmetcalfe.com> | 2015-04-19 11:27:51 -0500 |
---|---|---|
committer | Patrick Metcalfe <git@patrickmetcalfe.com> | 2015-04-19 11:27:51 -0500 |
commit | 7d87d6af10f86aee3ab1630334a3fb2eacbd45ff (patch) | |
tree | 026a35e569665d08c074da9f4638d72703fb45c6 /lib/bundler/installer.rb | |
parent | c7fce7422f467407f7544062661cbbb726b9ef38 (diff) | |
download | bundler-7d87d6af10f86aee3ab1630334a3fb2eacbd45ff.tar.gz |
refactor parallel installer
Diffstat (limited to 'lib/bundler/installer.rb')
-rw-r--r-- | lib/bundler/installer.rb | 43 |
1 files changed, 1 insertions, 42 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index 7365b8f27e..a3a2eabdc3 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -277,48 +277,7 @@ module Bundler end def install_in_parallel(size, standalone, force = false) - name2spec = {} - remains = {} - enqueued = {} - specs.each do |spec| - name2spec[spec.name] = spec - remains[spec.name] = true - end - - worker_pool = Worker.new size, lambda { |name, worker_num| - spec = name2spec[name] - message = install_gem_from_spec spec, standalone, worker_num, force - { :name => spec.name, :post_install => message } - } - - # Keys in the remains hash represent uninstalled gems specs. - # We enqueue all gem specs that do not have any dependencies. - # Later we call this lambda again to install specs that depended on - # previously installed specifications. We continue until all specs - # are installed. - enqueue_remaining_specs = lambda do - remains.keys.each do |name| - next if enqueued[name] - spec = name2spec[name] - if ready_to_install?(spec, remains) - worker_pool.enq name - enqueued[name] = true - end - end - end - enqueue_remaining_specs.call - - until remains.empty? - message = worker_pool.deq - remains.delete message[:name] - if message[:post_install] - Installer.post_install_messages[message[:name]] = message[:post_install] - end - enqueue_remaining_specs.call - end - message - ensure - worker_pool && worker_pool.stop + ParallelInstaller.call(self, specs, size, standalone, force) end # We only want to install a gem spec if all its dependencies are met. |