Class: Gem::Request::HTTPPool
- Inherits:
-
Object
- Object
- Gem::Request::HTTPPool
- 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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cert_files ⇒ Object
readonly
Returns the value of attribute cert_files.
-
#proxy_uri ⇒ Object
readonly
Returns the value of attribute proxy_uri.
Instance Method Summary collapse
- #checkin(connection) ⇒ Object
- #checkout ⇒ Object
- #close_all ⇒ Object
-
#initialize(http_args, cert_files, proxy_uri) ⇒ HTTPPool
constructor
A new instance of HTTPPool.
Constructor Details
#initialize(http_args, cert_files, proxy_uri) ⇒ HTTPPool
Returns a new instance of HTTPPool.
12 13 14 15 16 17 18 |
# 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 = SizedQueue.new 1 @queue << nil end |
Instance Attribute Details
#cert_files ⇒ Object (readonly)
Returns the value of attribute cert_files
10 11 12 |
# File 'lib/rubygems/request/http_pool.rb', line 10 def cert_files @cert_files end |
#proxy_uri ⇒ Object (readonly)
Returns the value of attribute proxy_uri
10 11 12 |
# File 'lib/rubygems/request/http_pool.rb', line 10 def proxy_uri @proxy_uri end |
Instance Method Details
#checkin(connection) ⇒ Object
24 25 26 |
# File 'lib/rubygems/request/http_pool.rb', line 24 def checkin(connection) @queue.push connection end |
#checkout ⇒ Object
20 21 22 |
# File 'lib/rubygems/request/http_pool.rb', line 20 def checkout @queue.pop || make_connection end |
#close_all ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/rubygems/request/http_pool.rb', line 28 def close_all until @queue.empty? if connection = @queue.pop(true) and connection.started? connection.finish end end @queue.push(nil) end |