class Protocol::HTTP2::Window
Attributes
available[R]
capacity[R]
used[R]
Public Class Methods
new(capacity = 0xFFFF)
click to toggle source
@param capacity [Integer] The initial window size, typically from the settings.
# File lib/protocol/http2/window_update_frame.rb, line 27 def initialize(capacity = 0xFFFF) # This is the main field required: @available = capacity # These two fields are primarily used for efficiently sending window updates: @used = 0 @capacity = capacity end
Public Instance Methods
available?()
click to toggle source
# File lib/protocol/http2/window_update_frame.rb, line 58 def available? @available > 0 end
capacity=(value)
click to toggle source
When the value of SETTINGS_INITIAL_WINDOW_SIZE changes, a receiver MUST adjust the size of all stream flow-control windows that it maintains by the difference between the new value and the old value.
# File lib/protocol/http2/window_update_frame.rb, line 45 def capacity= value difference = value - @capacity @available += difference @capacity = value end
consume(amount)
click to toggle source
# File lib/protocol/http2/window_update_frame.rb, line 51 def consume(amount) @available -= amount @used += amount end
expand(amount)
click to toggle source
# File lib/protocol/http2/window_update_frame.rb, line 62 def expand(amount) # puts "expand(#{amount}) @available=#{@available}" @available += amount @used -= amount if @available > MAXIMUM_ALLOWED_WINDOW_SIZE raise FlowControlError, "Expanding window by #{amount} caused overflow: #{@available} > #{MAXIMUM_ALLOWED_WINDOW_SIZE}!" end end
full?()
click to toggle source
The window is completely full?
# File lib/protocol/http2/window_update_frame.rb, line 37 def full? @available <= 0 end
limited?()
click to toggle source
# File lib/protocol/http2/window_update_frame.rb, line 76 def limited? @available < (@capacity / 2) end
to_s()
click to toggle source
# File lib/protocol/http2/window_update_frame.rb, line 80 def to_s "\#<Window used=#{@used} available=#{@available} capacity=#{@capacity}>" end
wanted()
click to toggle source
# File lib/protocol/http2/window_update_frame.rb, line 72 def wanted @used end