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?, #inspect

Constructor Details

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

Returns a new instance of LocalWindow.



80
81
82
83
84
# File 'lib/protocol/http2/window_update_frame.rb', line 80

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

Instance Attribute Details

#desiredObject

Returns the value of attribute desired.



86
87
88
# File 'lib/protocol/http2/window_update_frame.rb', line 86

def desired
  @desired
end

Instance Method Details

#limited?Boolean

Returns:

  • (Boolean)


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

def limited?
  if @desired
    @available < @desired
  else
    super
  end
end

#wantedObject



88
89
90
91
92
93
94
95
# File 'lib/protocol/http2/window_update_frame.rb', line 88

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