Class: 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
:nodoc:.
-
#proxy_uri ⇒ Object
readonly
:nodoc:.
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.
11 12 13 14 15 16 17 |
# 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 = SizedQueue.new 1 @queue << nil end |
Instance Attribute Details
#cert_files ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/rubygems/request/http_pool.rb', line 9 def cert_files @cert_files end |
#proxy_uri ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/rubygems/request/http_pool.rb', line 9 def proxy_uri @proxy_uri end |
Instance Method Details
#checkin(connection) ⇒ Object
23 24 25 |
# File 'lib/rubygems/request/http_pool.rb', line 23 def checkin(connection) @queue.push connection end |
#checkout ⇒ Object
19 20 21 |
# File 'lib/rubygems/request/http_pool.rb', line 19 def checkout @queue.pop || make_connection end |
#close_all ⇒ Object
27 28 29 30 31 32 33 34 |
# 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 |