Class: Gem::Net::HTTP::Persistent::TimedStackMulti
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Class Chain: | |
| Instance Chain: | |
| Inherits: | Bundler::ConnectionPool::TimedStack 
 | 
| Defined in: | lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb | 
Class Method Summary
- 
    
      .hash_of_arrays  
    
    Returns a new hash that has arrays for keys. 
- .new(size = 0, &block) ⇒ TimedStackMulti constructor
::Bundler::ConnectionPool::TimedStack - Inherited
| .new | Creates a new pool with  | 
Instance Attribute Summary
- #empty? ⇒ Boolean readonly
::Bundler::ConnectionPool::TimedStack - Inherited
Instance Method Summary
- #length
- #connection_stored?(options = {}) ⇒ Boolean private
- #fetch_connection(options = {}) private
- #lru_update(connection_args) private
- #shutdown_connections private
- #store_connection(obj, options = {}) private
- #try_create(options = {}) private
::Bundler::ConnectionPool::TimedStack - Inherited
| #<< | Alias for Bundler::ConnectionPool::TimedStack#push. | 
| #idle | The number of connections created and available on the stack. | 
| #length | The number of connections available on the stack. | 
| #pop | Retrieves a connection from the stack. | 
| #push | Returns  | 
| #reap | Reaps connections that were checked in more than  | 
| #shutdown | Shuts down the TimedStack by passing each connection to  | 
| #connection_stored? | This is an extension point for TimedStack and is called with a mutex. | 
| #current_time, | |
| #fetch_connection | This is an extension point for TimedStack and is called with a mutex. | 
| #idle_connections? | This is an extension point for TimedStack and is called with a mutex. | 
| #reserve_idle_connection | This is an extension point for TimedStack and is called with a mutex. | 
| #shutdown_connections | This is an extension point for TimedStack and is called with a mutex. | 
| #store_connection | This is an extension point for TimedStack and is called with a mutex. | 
| #try_create | This is an extension point for TimedStack and is called with a mutex. | 
Constructor Details
    .new(size = 0, &block)  ⇒ TimedStackMulti 
  
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb', line 13
def initialize(size = 0, &block) super @enqueued = 0 @ques = self.class.hash_of_arrays @lru = {} @key = :"connection_args-#{object_id}" end
Class Method Details
.hash_of_arrays
Returns a new hash that has arrays for keys
Using a class method to limit the bindings referenced by the hash’s default_proc
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb', line 9
def self.hash_of_arrays # :nodoc: Hash.new { |h,k| h[k] = [] } end
Instance Attribute Details
    #empty?  ⇒ Boolean  (readonly)
  
  [ GitHub ]
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb', line 22
def empty? (@created - @enqueued) >= @max end
Instance Method Details
    #connection_stored?(options = {})  ⇒ Boolean  (private)
  
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb', line 32
def connection_stored? = {} # :nodoc: !@ques[[:connection_args]].empty? end
#fetch_connection(options = {}) (private)
[ GitHub ]# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb', line 36
def fetch_connection = {} # :nodoc: connection_args = [:connection_args] @enqueued -= 1 lru_update connection_args @ques[connection_args].pop end
#length
[ GitHub ]# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb', line 26
def length @max - @created + @enqueued end
#lru_update(connection_args) (private)
[ GitHub ]# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb', line 44
def lru_update connection_args # :nodoc: @lru.delete connection_args @lru[connection_args] = true end
#shutdown_connections (private)
[ GitHub ]#store_connection(obj, options = {}) (private)
[ GitHub ]# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb', line 55
def store_connection obj, = {} # :nodoc: @ques[[:connection_args]].push obj @enqueued += 1 end
#try_create(options = {}) (private)
[ GitHub ]# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb', line 60
def try_create = {} # :nodoc: connection_args = [:connection_args] if @created >= @max && @enqueued >= 1 oldest, = @lru.first @lru.delete oldest @ques[oldest].pop @created -= 1 end if @created < @max @created += 1 lru_update connection_args return @create_block.call(connection_args) end end