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:
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.
13 14 15 16 17 18 19 20 |
# File '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 ⇒ 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
9 10 11 |
# File '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
22 23 24 |
# File 'lib/net/http/persistent/timed_stack_multi.rb', line 22 def empty? (@created - @enqueued) >= @max end |
#length ⇒ Object
26 27 28 |
# File 'lib/net/http/persistent/timed_stack_multi.rb', line 26 def length @max - @created + @enqueued end |