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 11

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 9

attr_reader :cert_files, :proxy_uri

#proxy_uri (readonly)

[ GitHub ]

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

attr_reader :cert_files, :proxy_uri

Instance Method Details

#checkin(connection)

[ GitHub ]

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

def checkin(connection)
  @queue.push connection
end

#checkout

[ GitHub ]

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

def checkout
  @queue.pop || make_connection
end

#close_all

[ GitHub ]

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

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

#make_connection (private)

[ GitHub ]

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

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 42

def setup_connection(connection)
  connection.start
  connection
end