diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-18 08:37:18 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-18 08:37:18 +0000 |
commit | ec6c07570237b209d47b7690a5b5a6774301242b (patch) | |
tree | 70902f2e19499bb3bd26f014aa12bb43b96e9b22 /lib/rubygems/request_set.rb | |
parent | 3367daf716bda6e73f3418dd601bd1713d557c07 (diff) |
Merge upstream revision of rubygems/rubygems.
This commits includes tiny bugfix and new features listed here:
* Add --re-sign flag to cert command by bronzdoc: https://github.com/rubygems/rubygems/pull/2391
* Download gems with threads. by indirect: https://github.com/rubygems/rubygems/pull/1898
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/request_set.rb')
-rw-r--r-- | lib/rubygems/request_set.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb index ed99d29295..c68e40ee9e 100644 --- a/lib/rubygems/request_set.rb +++ b/lib/rubygems/request_set.rb @@ -152,7 +152,34 @@ class Gem::RequestSet @prerelease = options[:prerelease] requests = [] + download_queue = Queue.new + # Create a thread-safe list of gems to download + sorted_requests.each do |req| + download_queue << req + end + + # Create N threads in a pool, have them download all the gems + threads = Gem.configuration.concurrent_downloads.times.map do + # When a thread pops this item, it knows to stop running. The symbol + # is queued here so that there will be one symbol per thread. + download_queue << :stop + + Thread.new do + # The pop method will block waiting for items, so the only way + # to stop a thread from running is to provide a final item that + # means the thread should stop. + while req = download_queue.pop + break if req == :stop + req.spec.download options unless req.installed? + end + end + end + + # Wait for all the downloads to finish before continuing + threads.each(&:value) + + # Install requested gems after they have been downloaded sorted_requests.each do |req| if req.installed? then req.spec.spec.build_extensions |