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.
- #limited? ⇒ Boolean
- #to_s ⇒ Object
- #wanted ⇒ Object
Constructor Details
#initialize(capacity = 0xFFFF) ⇒ Window
Returns a new instance of Window.
27 28 29 30 31 32 33 34 |
# 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 |
Instance Attribute Details
#available ⇒ Object (readonly)
Returns the value of attribute available.
56 57 58 |
# File 'lib/protocol/http2/window_update_frame.rb', line 56 def available @available end |
#capacity ⇒ Object
Returns the value of attribute capacity.
42 43 44 |
# File 'lib/protocol/http2/window_update_frame.rb', line 42 def capacity @capacity end |
#used ⇒ Object (readonly)
Returns the value of attribute used.
41 42 43 |
# File 'lib/protocol/http2/window_update_frame.rb', line 41 def used @used end |
Instance Method Details
#available? ⇒ Boolean
58 59 60 |
# File 'lib/protocol/http2/window_update_frame.rb', line 58 def available? @available > 0 end |
#consume(amount) ⇒ Object
51 52 53 54 |
# File 'lib/protocol/http2/window_update_frame.rb', line 51 def consume(amount) @available -= amount @used += amount end |
#expand(amount) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/protocol/http2/window_update_frame.rb', line 62 def (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? ⇒ Boolean
The window is completely full?
37 38 39 |
# File 'lib/protocol/http2/window_update_frame.rb', line 37 def full? @available <= 0 end |
#limited? ⇒ Boolean
76 77 78 |
# File 'lib/protocol/http2/window_update_frame.rb', line 76 def limited? @available < (@capacity / 2) end |
#to_s ⇒ Object
80 81 82 |
# File 'lib/protocol/http2/window_update_frame.rb', line 80 def to_s "\#<Window used=#{@used} available=#{@available} capacity=#{@capacity}>" end |
#wanted ⇒ Object
72 73 74 |
# File 'lib/protocol/http2/window_update_frame.rb', line 72 def wanted @used end |