Class: Gem::Net::HTTP::Persistent::TimedStackMulti

Inherits:
Bundler::ConnectionPool::TimedStack
  • Object
show all
Defined in:
lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size = 0, &block) ⇒ TimedStackMulti

Returns a new instance of TimedStackMulti.



13
14
15
16
17
18
19
20
# 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_arraysObject

Returns a new hash that has arrays for keys

Using a class method to limit the bindings referenced by the hash’s default_proc



9
10
11
# 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 Method Details

#empty?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb', line 22

def empty?
  (@created - @enqueued) >= @max
end

#lengthObject



26
27
28
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb', line 26

def length
  @max - @created + @enqueued
end