proxygen
|
#include <Window.h>
Public Member Functions | |
Window (uint32_t capacity) | |
int32_t | getSize () const |
uint32_t | getNonNegativeSize () const |
uint32_t | getCapacity () const |
uint32_t | getOutstanding () const |
bool | reserve (uint32_t amount, bool strict=true) |
bool | free (uint32_t amount) |
bool | setCapacity (uint32_t capacity) |
Private Attributes | |
int32_t | outstanding_ {0} |
int32_t | capacity_ {0} |
A class that implements SPDY & HTTP/2 window management. This class should be used for both connection and stream level flow control.
|
explicit |
Constructs a new Window.
capacity | The initial capacity of this Window. The initial size will also be equal to this. This parameter must not be > 2^31 -1 |
Definition at line 19 of file Window.cpp.
References setCapacity().
bool proxygen::Window::free | ( | uint32_t | amount | ) |
Increment the window size by amount. Decrease bytes outstanding by amount. The window size could become greater than the capacity here.
Definition at line 63 of file Window.cpp.
References capacity_, int32_t, max, min, and outstanding_.
Referenced by proxygen::FlowControlFilter::ingressBytesProcessed(), proxygen::FlowControlFilter::onBody(), proxygen::HTTPTransaction::onIngressBody(), proxygen::HTTPTransaction::onIngressWindowUpdate(), proxygen::FlowControlFilter::onWindowUpdate(), proxygen::HTTPTransaction::resumeIngress(), and TEST().
uint32_t proxygen::Window::getCapacity | ( | ) | const |
Returns the size of the initial window. That is, the total number of bytes allowed to be outstanding on this window.
Definition at line 32 of file Window.cpp.
References capacity_, and uint32_t.
Referenced by proxygen::HTTPTransaction::flushWindowUpdate(), proxygen::FlowControlFilter::ingressBytesProcessed(), proxygen::HTTPTransaction::onIngressBody(), proxygen::HTTPTransaction::onIngressSetSendWindow(), proxygen::HTTPTransaction::onIngressWindowUpdate(), proxygen::HTTPTransaction::processIngressBody(), proxygen::HTTPTransaction::sendBodyNow(), proxygen::HTTPTransaction::setReceiveWindow(), proxygen::FlowControlFilter::setReceiveWindowSize(), and TEST().
uint32_t proxygen::Window::getNonNegativeSize | ( | ) | const |
Returns the number of bytes available to be consumed in this window. If that number went negative somehow, this function clamps the return value to zero.
Definition at line 27 of file Window.cpp.
References getSize(), and folly::size().
Referenced by proxygen::FlowControlFilter::generateBody(), proxygen::FlowControlFilter::getAvailableSend(), and proxygen::FlowControlFilter::onWindowUpdate().
uint32_t proxygen::Window::getOutstanding | ( | ) | const |
Returns the number of bytes reserved in this window. If multiple calls to free() caused this number to go negative, this function returns 0.
Definition at line 37 of file Window.cpp.
References outstanding_.
Referenced by proxygen::HTTPTransaction::onDelayedDestroy(), proxygen::HTTPTransaction::onIngressBody(), proxygen::HTTPTransaction::onIngressSetSendWindow(), proxygen::HTTPTransaction::onIngressWindowUpdate(), proxygen::FlowControlFilter::onWindowUpdate(), and TEST().
int32_t proxygen::Window::getSize | ( | ) | const |
Returns the number of bytes available to be consumed in this window. This could become a negative number if the initial window is set to a smaller number.
Definition at line 23 of file Window.cpp.
References capacity_, and outstanding_.
Referenced by proxygen::HTTPTransaction::flushWindowUpdate(), proxygen::FlowControlFilter::generateBody(), getNonNegativeSize(), proxygen::HTTPTransaction::isExpectingWindowUpdate(), proxygen::HTTPTransaction::notifyTransportPendingEgress(), proxygen::FlowControlFilter::onBody(), proxygen::FlowControlFilter::onWindowUpdate(), proxygen::HTTPTransaction::sendBodyNow(), proxygen::HTTPTransaction::sendDeferredBody(), setCapacity(), TEST(), and proxygen::HTTPTransaction::updateHandlerPauseState().
bool proxygen::Window::reserve | ( | uint32_t | amount, |
bool | strict = true |
||
) |
amount | The amount to reduce the window size by. Increases bytes outstanding by amount. |
strict | If true, reserve() will return false if there is no space remaining in the window. If false, reserve() will return true until the integer overflows. |
Definition at line 41 of file Window.cpp.
References capacity_, int32_t, max, and outstanding_.
Referenced by proxygen::FlowControlFilter::generateBody(), proxygen::FlowControlFilter::onBody(), proxygen::HTTPTransaction::onIngressBody(), proxygen::HTTPTransaction::sendBodyNow(), and TEST().
bool proxygen::Window::setCapacity | ( | uint32_t | capacity | ) |
Sets a new initial window size. This will also apply the delta between the current window size and the new window size. Returns false iff applying the new initial window fails.
Definition at line 84 of file Window.cpp.
References capacity_, diff(), getSize(), int32_t, max, and folly::size().
Referenced by proxygen::FlowControlFilter::FlowControlFilter(), proxygen::HTTPTransaction::onIngressSetSendWindow(), proxygen::HTTPTransaction::reset(), proxygen::HTTPTransaction::setReceiveWindow(), proxygen::FlowControlFilter::setReceiveWindowSize(), TEST(), and Window().
|
private |
Definition at line 81 of file Window.h.
Referenced by free(), getCapacity(), getSize(), reserve(), and setCapacity().
|
private |