class Protocol::HTTP2::Window

def available?

def available?
	@available > 0
end

def capacity= value

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.
def capacity= value
	difference = value - @capacity
	
	# An endpoint MUST treat a change to SETTINGS_INITIAL_WINDOW_SIZE that causes any flow-control window to exceed the maximum size as a connection error of type FLOW_CONTROL_ERROR.
	if (@available + difference) > MAXIMUM_ALLOWED_WINDOW_SIZE
		raise FlowControlError, "Changing window size by #{difference} caused overflow: #{@available + difference} > #{MAXIMUM_ALLOWED_WINDOW_SIZE}!"
	end
	
	@available += difference
	@capacity = value
end

def consume(amount)

def consume(amount)
	@available -= amount
	@used += amount
end

def expand(amount)

def expand(amount)
	available = @available + amount
	
	if available > MAXIMUM_ALLOWED_WINDOW_SIZE
		raise FlowControlError, "Expanding window by #{amount} caused overflow: #{available} > #{MAXIMUM_ALLOWED_WINDOW_SIZE}!"
	end
	
	# puts "expand(#{amount}) @available=#{@available}"
	@available += amount
	@used -= amount
end

def full?

The window is completely full?
def full?
	@available <= 0
end

def initialize(capacity = 0xFFFF)

Parameters:
  • capacity (Integer) -- The initial window size, typically from the settings.
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

def inspect

def inspect
	"\#<#{self.class} used=#{@used} available=#{@available} capacity=#{@capacity}>"
end

def limited?

def limited?
	@available < (@capacity / 2)
end

def wanted

def wanted
	@used
end