Class: Protocol::HTTP2::LocalWindow
- Defined in:
- lib/protocol/http2/window.rb
Overview
This is a window which efficiently maintains a desired capacity.
Constant Summary
Constants inherited from Window
Instance Attribute Summary collapse
-
#desired ⇒ Object
The desired capacity of the window.
Attributes inherited from Window
Instance Method Summary collapse
-
#initialize(capacity = DEFAULT_CAPACITY, desired: nil) ⇒ LocalWindow
constructor
A new instance of LocalWindow.
- #inspect ⇒ Object
- #limited? ⇒ Boolean
- #wanted ⇒ Object
Methods inherited from Window
#available?, #consume, #expand, #full?
Constructor Details
#initialize(capacity = DEFAULT_CAPACITY, desired: nil) ⇒ LocalWindow
Returns a new instance of LocalWindow.
83 84 85 86 87 88 89 |
# File 'lib/protocol/http2/window.rb', line 83 def initialize(capacity = DEFAULT_CAPACITY, desired: nil) super(capacity) # The desired capacity of the window, may be bigger than the initial capacity. # If that is the case, we will likely send a window update to the remote end to increase the capacity. @desired = desired end |
Instance Attribute Details
#desired ⇒ Object
The desired capacity of the window.
92 93 94 |
# File 'lib/protocol/http2/window.rb', line 92 def desired @desired end |
Instance Method Details
#inspect ⇒ Object
112 113 114 |
# File 'lib/protocol/http2/window.rb', line 112 def inspect "\#<#{self.class} available=#{@available} used=#{@used} capacity=#{@capacity} desired=#{@desired} #{limited? ? "limited" : nil}>" end |
#limited? ⇒ Boolean
103 104 105 106 107 108 109 110 |
# File 'lib/protocol/http2/window.rb', line 103 def limited? if @desired # Do not send window updates until we are less than half the desired capacity: @available < (@desired / 2) else super end end |
#wanted ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/protocol/http2/window.rb', line 94 def wanted if @desired # We must send an update which allows at least @desired bytes to be sent. (@desired - @capacity) + @used else super end end |