Base class for Squid-to-client bandwidth limiting. More...
#include <BandwidthBucket.h>
Public Member Functions | |
BandwidthBucket (const int speed, const int initialLevelPercent, const double sizeLimit) | |
virtual | ~BandwidthBucket () |
virtual int | quota ()=0 |
virtual bool | applyQuota (int &nleft, Comm::IoCallback *state) |
virtual void | scheduleWrite (Comm::IoCallback *state)=0 |
Will plan another write call. More... | |
virtual void | onFdClosed () |
Performs cleanup when the related file descriptor becomes closed. More... | |
virtual void | reduceBucket (const int len) |
Decreases the bucket level. More... | |
bool | noLimit () const |
Whether this bucket will not do bandwidth limiting. More... | |
Static Public Member Functions | |
static BandwidthBucket * | SelectBucket (fde *f) |
Public Attributes | |
double | bucketLevel |
how much can be written now More... | |
bool | selectWaiting |
is between commSetSelect and commHandleWrite More... | |
Protected Member Functions | |
void | refillBucket () |
Increases the bucket level with the writeSpeedLimit speed. More... | |
Protected Attributes | |
double | prevTime |
previous time when we checked More... | |
double | writeSpeedLimit |
Write speed limit in bytes per second. More... | |
double | bucketSizeLimit |
maximum bucket size More... | |
Detailed Description
Definition at line 19 of file BandwidthBucket.h.
Constructor & Destructor Documentation
◆ BandwidthBucket()
BandwidthBucket::BandwidthBucket | ( | const int | speed, |
const int | initialLevelPercent, | ||
const double | sizeLimit | ||
) |
Definition at line 19 of file BandwidthBucket.cc.
References current_dtime, getCurrentTime(), and prevTime.
◆ ~BandwidthBucket()
|
inlinevirtual |
Definition at line 23 of file BandwidthBucket.h.
Member Function Documentation
◆ applyQuota()
|
virtual |
Adjusts nleft to not exceed the current bucket quota value, if needed.
Reimplemented in ClientInfo.
Definition at line 66 of file BandwidthBucket.cc.
References Comm::IoCallback::conn, debugs, min(), and quota().
Referenced by ClientInfo::applyQuota().
◆ noLimit()
|
inline |
Definition at line 41 of file BandwidthBucket.h.
References writeSpeedLimit.
Referenced by MessageBucket::quota(), reduceBucket(), and refillBucket().
◆ onFdClosed()
|
inlinevirtual |
Reimplemented in ClientInfo.
Definition at line 37 of file BandwidthBucket.h.
References selectWaiting.
Referenced by ClientInfo::onFdClosed().
◆ quota()
|
pure virtual |
- Returns
- the number of bytes this bucket allows to write, also considering aggregates, if any. Negative quota means no limitations by this bucket.
Implemented in ClientInfo, and MessageBucket.
Referenced by applyQuota().
◆ reduceBucket()
|
virtual |
Reimplemented in ClientInfo, and MessageBucket.
Definition at line 83 of file BandwidthBucket.cc.
References bucketLevel, DBG_IMPORTANT, debugs, and noLimit().
Referenced by ClientInfo::reduceBucket(), and MessageBucket::reduceBucket().
◆ refillBucket()
|
protected |
Definition at line 31 of file BandwidthBucket.cc.
References bucketLevel, bucketSizeLimit, current_dtime, debugs, noLimit(), prevTime, and writeSpeedLimit.
Referenced by ClientInfo::quota(), and MessageBucket::quota().
◆ scheduleWrite()
|
pure virtual |
Implemented in ClientInfo, and MessageBucket.
◆ SelectBucket()
|
static |
Definition at line 95 of file BandwidthBucket.cc.
References fde::clientInfo, RefCount< C >::getRaw(), ClientInfo::writeLimitingActive, and fde::writeQuotaHandler.
Referenced by _comm_close(), and Comm::IoCallback::selectOrQueueWrite().
Member Data Documentation
◆ bucketLevel
double BandwidthBucket::bucketLevel |
Definition at line 48 of file BandwidthBucket.h.
Referenced by ClientInfo::kickQuotaQueue(), ClientInfo::quota(), MessageBucket::quota(), reduceBucket(), refillBucket(), and ClientInfo::setWriteLimiter().
◆ bucketSizeLimit
|
protected |
Definition at line 54 of file BandwidthBucket.h.
Referenced by refillBucket(), and ClientInfo::setWriteLimiter().
◆ prevTime
|
protected |
Definition at line 52 of file BandwidthBucket.h.
Referenced by BandwidthBucket(), refillBucket(), and ClientInfo::setWriteLimiter().
◆ selectWaiting
bool BandwidthBucket::selectWaiting |
Definition at line 49 of file BandwidthBucket.h.
Referenced by commHandleWriteHelper(), ClientInfo::kickQuotaQueue(), onFdClosed(), ClientInfo::setWriteLimiter(), and ClientInfo::writeOrDequeue().
◆ writeSpeedLimit
|
protected |
Definition at line 53 of file BandwidthBucket.h.
Referenced by noLimit(), refillBucket(), and ClientInfo::setWriteLimiter().
The documentation for this class was generated from the following files:
- src/BandwidthBucket.h
- src/BandwidthBucket.cc