123456789_123456789_123456789_123456789_123456789_

Class: Gem::Request::HTTPPool

Do not use. This class is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object
Defined in: lib/rubygems/request/http_pool.rb

Overview

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 Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(http_args, cert_files, proxy_uri) ⇒ HTTPPool

[ GitHub ]

  
# File 'lib/rubygems/request/http_pool.rb', line 12

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

Instance Attribute Details

#cert_files (readonly)

[ GitHub ]

  
# File 'lib/rubygems/request/http_pool.rb', line 10

attr_reader :cert_files, :proxy_uri

#proxy_uri (readonly)

[ GitHub ]

  
# File 'lib/rubygems/request/http_pool.rb', line 10

attr_reader :cert_files, :proxy_uri

Instance Method Details

#checkin(connection)

[ GitHub ]

  
# File 'lib/rubygems/request/http_pool.rb', line 24

def checkin(connection)
  @queue.push connection
end

#checkout

[ GitHub ]

  
# File 'lib/rubygems/request/http_pool.rb', line 20

def checkout
  @queue.pop || make_connection
end

#close_all

[ GitHub ]

  
# File 'lib/rubygems/request/http_pool.rb', line 28

def close_all
  until @queue.empty?
    if (connection = @queue.pop(true)) && connection.started?
      connection.finish
    end
  end
  @queue.push(nil)
end

#make_connection (private)

[ GitHub ]

  
# File 'lib/rubygems/request/http_pool.rb', line 39

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

#setup_connection(connection) (private)

[ GitHub ]

  
# File 'lib/rubygems/request/http_pool.rb', line 43

def setup_connection(connection)
  connection.start
  connection
end