Class: Net::HTTP::Persistent::TimedStackMulti
- Inherits:
-
ConnectionPool::TimedStack
- Object
- ConnectionPool::TimedStack
- Net::HTTP::Persistent::TimedStackMulti
- Defined in:
- lib/net/http/persistent/timed_stack_multi.rb
Overview
:nodoc:
Constant Summary collapse
- CP_USES_KEYWORD_ARGS =
Detects if ConnectionPool 3.0+ is being used (needed for TimedStack subclass compatibility)
Gem::Version.new(ConnectionPool::VERSION) >= Gem::Version.new('3.0.0')
Class Method Summary collapse
-
.hash_of_arrays ⇒ Object
Returns a new hash that has arrays for keys.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(size = 0, &block) ⇒ TimedStackMulti
constructor
A new instance of TimedStackMulti.
- #length ⇒ Object
Constructor Details
#initialize(size = 0, &block) ⇒ TimedStackMulti
Returns a new instance of TimedStackMulti.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/net/http/persistent/timed_stack_multi.rb', line 18 def initialize(size = 0, &block) if CP_USES_KEYWORD_ARGS super(size: size, &block) else super(size, &block) end @enqueued = 0 @ques = self.class.hash_of_arrays @lru = {} @key = :"connection_args-#{object_id}" end |
Class Method Details
.hash_of_arrays ⇒ Object
Returns a new hash that has arrays for keys
Using a class method to limit the bindings referenced by the hash’s default_proc
14 15 16 |
# File 'lib/net/http/persistent/timed_stack_multi.rb', line 14 def self.hash_of_arrays # :nodoc: Hash.new { |h,k| h[k] = [] } end |
Instance Method Details
#empty? ⇒ Boolean
31 32 33 |
# File 'lib/net/http/persistent/timed_stack_multi.rb', line 31 def empty? (@created - @enqueued) >= @max end |
#length ⇒ Object
35 36 37 |
# File 'lib/net/http/persistent/timed_stack_multi.rb', line 35 def length @max - @created + @enqueued end |