Class: Protocol::HTTP2::LocalWindow

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

Overview

This is a window which efficiently maintains a desired capacity.

Instance Attribute Summary collapse

Attributes inherited from Window

#available, #capacity, #used

Instance Method Summary collapse

Methods inherited from Window

#available?, #consume, #expand, #full?, #to_s

Constructor Details

#initialize(capacity = 0xFFFF, desired: nil) ⇒ LocalWindow



87
88
89
90
91
# File 'lib/protocol/http2/window_update_frame.rb', line 87

def initialize(capacity = 0xFFFF, desired: nil)
  super(capacity)
  
  @desired = desired
end

Instance Attribute Details

#desiredObject

Returns the value of attribute desired.



93
94
95
# File 'lib/protocol/http2/window_update_frame.rb', line 93

def desired
  @desired
end

Instance Method Details

#limited?Boolean



104
105
106
# File 'lib/protocol/http2/window_update_frame.rb', line 104

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

#wantedObject



95
96
97
98
99
100
101
102
# File 'lib/protocol/http2/window_update_frame.rb', line 95

def wanted
  if @desired
    # We must send an update which allows at least @desired bytes to be sent.
    (@desired - @capacity) + @used
  else
    @used
  end
end