Class: HTTP::Protocol::HTTP2::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/http/protocol/http2/window_update_frame.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(capacity = 0xFFFF) ⇒ Window

Returns a new instance of Window.

Parameters:

  • capacity (Integer) (defaults to: 0xFFFF)

    The initial window size, typically from the settings.



26
27
28
29
30
31
32
33
34
35
# File 'lib/http/protocol/http2/window_update_frame.rb', line 26

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
	
	fail unless capacity
end

Instance Attribute Details

#availableObject (readonly)

Returns the value of attribute available.



60
61
62
# File 'lib/http/protocol/http2/window_update_frame.rb', line 60

def available
  @available
end

#capacityObject

Returns the value of attribute capacity.



47
48
49
# File 'lib/http/protocol/http2/window_update_frame.rb', line 47

def capacity
  @capacity
end

#usedObject (readonly)

Returns the value of attribute used.



46
47
48
# File 'lib/http/protocol/http2/window_update_frame.rb', line 46

def used
  @used
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/http/protocol/http2/window_update_frame.rb', line 62

def available?
	@available > 0
end

#consume(amount) ⇒ Object



55
56
57
58
# File 'lib/http/protocol/http2/window_update_frame.rb', line 55

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

#dupObject



37
38
39
# File 'lib/http/protocol/http2/window_update_frame.rb', line 37

def dup
	return self.class.new(@capacity)
end

#expand(amount) ⇒ Object



66
67
68
69
# File 'lib/http/protocol/http2/window_update_frame.rb', line 66

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

#full?Boolean

The window is completely full?

Returns:

  • (Boolean)


42
43
44
# File 'lib/http/protocol/http2/window_update_frame.rb', line 42

def full?
	@available.zero?
end

#limited?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/http/protocol/http2/window_update_frame.rb', line 71

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

#to_sObject



75
76
77
# File 'lib/http/protocol/http2/window_update_frame.rb', line 75

def to_s
	"\#<Window used=#{@used} available=#{@available} capacity=#{@capacity}>"
end