Class: Protocol::HTTP2::Window
- Inherits:
-
Object
- Object
- Protocol::HTTP2::Window
- Defined in:
- lib/protocol/http2/window_update_frame.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#available ⇒ Object
readonly
Returns the value of attribute available.
-
#capacity ⇒ Object
Returns the value of attribute capacity.
-
#used ⇒ Object
readonly
Returns the value of attribute used.
Instance Method Summary collapse
- #available? ⇒ Boolean
- #consume(amount) ⇒ Object
- #expand(amount) ⇒ Object
-
#full? ⇒ Boolean
The window is completely full?.
-
#initialize(capacity = 0xFFFF) ⇒ Window
constructor
A new instance of Window.
- #inspect ⇒ Object
- #limited? ⇒ Boolean
- #wanted ⇒ Object
Constructor Details
#initialize(capacity = 0xFFFF) ⇒ Window
Returns a new instance of Window.
12 13 14 15 16 17 18 19 |
# File 'lib/protocol/http2/window_update_frame.rb', line 12 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 |
Instance Attribute Details
#available ⇒ Object (readonly)
Returns the value of attribute available.
47 48 49 |
# File 'lib/protocol/http2/window_update_frame.rb', line 47 def available @available end |
#capacity ⇒ Object
Returns the value of attribute capacity.
27 28 29 |
# File 'lib/protocol/http2/window_update_frame.rb', line 27 def capacity @capacity end |
#used ⇒ Object (readonly)
Returns the value of attribute used.
26 27 28 |
# File 'lib/protocol/http2/window_update_frame.rb', line 26 def used @used end |
Instance Method Details
#available? ⇒ Boolean
49 50 51 |
# File 'lib/protocol/http2/window_update_frame.rb', line 49 def available? @available > 0 end |
#consume(amount) ⇒ Object
42 43 44 45 |
# File 'lib/protocol/http2/window_update_frame.rb', line 42 def consume(amount) @available -= amount @used += amount end |
#expand(amount) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/protocol/http2/window_update_frame.rb', line 53 def (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 |
#full? ⇒ Boolean
The window is completely full?
22 23 24 |
# File 'lib/protocol/http2/window_update_frame.rb', line 22 def full? @available <= 0 end |
#inspect ⇒ Object
73 74 75 |
# File 'lib/protocol/http2/window_update_frame.rb', line 73 def inspect "\#<#{self.class} used=#{@used} available=#{@available} capacity=#{@capacity}>" end |
#limited? ⇒ Boolean
69 70 71 |
# File 'lib/protocol/http2/window_update_frame.rb', line 69 def limited? @available < (@capacity / 2) end |
#wanted ⇒ Object
65 66 67 |
# File 'lib/protocol/http2/window_update_frame.rb', line 65 def wanted @used end |