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
: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, pool_size) ⇒ HTTPPool
constructor
A new instance of HTTPPool.
Constructor Details
#initialize(http_args, cert_files, proxy_uri, pool_size) ⇒ HTTPPool
Returns a new instance of HTTPPool.
12 13 14 15 16 17 18 19 20 |
# File 'lib/rubygems/request/http_pool.rb', line 12 def initialize(http_args, cert_files, proxy_uri, pool_size) @http_args = http_args @cert_files = cert_files @proxy_uri = proxy_uri @pool_size = pool_size @queue = Thread::SizedQueue.new @pool_size setup_queue end |
Instance Attribute Details
#cert_files ⇒ Object (readonly)
:nodoc:
10 11 12 |
# File 'lib/rubygems/request/http_pool.rb', line 10 def cert_files @cert_files end |
#proxy_uri ⇒ Object (readonly)
:nodoc:
10 11 12 |
# File 'lib/rubygems/request/http_pool.rb', line 10 def proxy_uri @proxy_uri end |
Instance Method Details
#checkin(connection) ⇒ Object
26 27 28 |
# File 'lib/rubygems/request/http_pool.rb', line 26 def checkin(connection) @queue.push connection end |
#checkout ⇒ Object
22 23 24 |
# File 'lib/rubygems/request/http_pool.rb', line 22 def checkout @queue.pop || make_connection end |
#close_all ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/rubygems/request/http_pool.rb', line 30 def close_all until @queue.empty? if (connection = @queue.pop(true)) && connection.started? connection.finish end end setup_queue end |