Sha256: 686e8149806c79b5a2c9c6b0ab2bd9f47b0efffe1e601b814aec670218d6ce30

Contents?: true

Size: 824 Bytes

Versions: 6

Compression:

Stored size: 824 Bytes

Contents

##
# A connection "pool" that only manages one connection for now.  Provides
# thread safe `checkout` and `checkin` methods.  The pool consists of one
# connection that corresponds to `http_args`.  This class is private, do not
# use it.

class Gem::Request::HTTPPool # :nodoc:
  attr_reader :cert_files, :proxy_uri

  def initialize http_args, cert_files, proxy_uri
    @http_args  = http_args
    @cert_files = cert_files
    @proxy_uri  = proxy_uri
    @queue      = SizedQueue.new 1
    @queue << nil
  end

  def checkout
    @queue.pop || make_connection
  end

  def checkin connection
    @queue.push connection
  end

  private

  def make_connection
    setup_connection Gem::Request::ConnectionPools.client.new(*@http_args)
  end

  def setup_connection connection
    connection.start
    connection
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubygems-update-2.4.4 lib/rubygems/request/http_pool.rb
rubygems-update-2.4.3 lib/rubygems/request/http_pool.rb
rubygems-update-2.4.2 lib/rubygems/request/http_pool.rb
rubygems-update-2.4.1 lib/rubygems/request/http_pool.rb
rubygems-update-2.4.0 lib/rubygems/request/http_pool.rb
rubygems-update-2.3.0 lib/rubygems/request/http_pool.rb