Class: Bundler::Persistent::Net::HTTP::Persistent::Pool
- Inherits:
-
ConnectionPool
- Object
- ConnectionPool
- Bundler::Persistent::Net::HTTP::Persistent::Pool
- Defined in:
- lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb
Overview
:nodoc:
Constant Summary
Constants inherited from ConnectionPool
ConnectionPool::DEFAULTS, ConnectionPool::VERSION
Instance Attribute Summary collapse
-
#available ⇒ Object
readonly
:nodoc:.
-
#key ⇒ Object
readonly
:nodoc:.
Attributes inherited from ConnectionPool
Instance Method Summary collapse
- #checkin(net_http_args) ⇒ Object
- #checkout(net_http_args) ⇒ Object
-
#initialize(options = {}, &block) ⇒ Pool
constructor
A new instance of Pool.
- #shutdown ⇒ Object
Methods inherited from ConnectionPool
Constructor Details
#initialize(options = {}, &block) ⇒ Pool
Returns a new instance of Pool.
6 7 8 9 10 11 |
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb', line 6 def initialize( = {}, &block) super @available = Bundler::Persistent::Net::HTTP::Persistent::TimedStackMulti.new(@size, &block) @key = "current-#{@available.object_id}" end |
Instance Attribute Details
#available ⇒ Object (readonly)
:nodoc:
3 4 5 |
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb', line 3 def available @available end |
#key ⇒ Object (readonly)
:nodoc:
4 5 6 |
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb', line 4 def key @key end |
Instance Method Details
#checkin(net_http_args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb', line 13 def checkin net_http_args stack = Thread.current[@key][net_http_args] ||= [] raise Bundler::ConnectionPool::Error, 'no connections are checked out' if stack.empty? conn = stack.pop if stack.empty? @available.push conn, connection_args: net_http_args Thread.current[@key].delete(net_http_args) Thread.current[@key] = nil if Thread.current[@key].empty? end nil end |
#checkout(net_http_args) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb', line 31 def checkout net_http_args stacks = Thread.current[@key] ||= {} stack = stacks[net_http_args] ||= [] if stack.empty? then conn = @available.pop connection_args: net_http_args else conn = stack.last end stack.push conn conn end |
#shutdown ⇒ Object
46 47 48 49 |
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb', line 46 def shutdown Thread.current[@key] = nil super end |