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
Initialize a local window with optional desired capacity.
-
#inspect ⇒ Object
Get a string representation of the local window.
-
#limited? ⇒ Boolean
Check if the window is limited, considering desired capacity.
-
#wanted ⇒ Object
Get the amount of window that should be reclaimed, considering desired capacity.
Methods inherited from Window
#available?, #consume, #expand, #full?
Constructor Details
#initialize(capacity = DEFAULT_CAPACITY, desired: nil) ⇒ LocalWindow
Initialize a local window with optional desired capacity.
101 102 103 104 105 106 107 |
# File 'lib/protocol/http2/window.rb', line 101 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.
110 111 112 |
# File 'lib/protocol/http2/window.rb', line 110 def desired @desired end |
Instance Method Details
#inspect ⇒ Object
Get a string representation of the local window.
136 137 138 |
# File 'lib/protocol/http2/window.rb', line 136 def inspect "\#<#{self.class} available=#{@available} used=#{@used} capacity=#{@capacity} desired=#{@desired} #{limited? ? "limited" : nil}>" end |
#limited? ⇒ Boolean
Check if the window is limited, considering desired capacity.
125 126 127 128 129 130 131 132 |
# File 'lib/protocol/http2/window.rb', line 125 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
Get the amount of window that should be reclaimed, considering desired capacity.
114 115 116 117 118 119 120 121 |
# File 'lib/protocol/http2/window.rb', line 114 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 |