BandwidthBucket.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef BANDWIDTHBUCKET_H
10 #define BANDWIDTHBUCKET_H
11 
12 #if USE_DELAY_POOLS
13 
14 #include "comm/IoCallback.h"
15 
16 class fde;
17 
20 {
21 public:
22  BandwidthBucket(const int speed, const int initialLevelPercent, const double sizeLimit);
23  virtual ~BandwidthBucket() {}
24 
25  static BandwidthBucket *SelectBucket(fde *f);
26 
30  virtual int quota() = 0;
33  virtual bool applyQuota(int &nleft, Comm::IoCallback *state);
35  virtual void scheduleWrite(Comm::IoCallback *state) = 0;
37  virtual void onFdClosed() { selectWaiting = false; }
39  virtual void reduceBucket(const int len);
41  bool noLimit() const { return writeSpeedLimit < 0; }
42 
43 protected:
45  void refillBucket();
46 
47 public:
48  double bucketLevel;
50 
51 protected:
52  double prevTime;
53  double writeSpeedLimit;
54  double bucketSizeLimit;
55 };
56 
57 #endif /* USE_DELAY_POOLS */
58 
59 #endif
60 
bool noLimit() const
Whether this bucket will not do bandwidth limiting.
virtual void scheduleWrite(Comm::IoCallback *state)=0
Will plan another write call.
Definition: fde.h:52
double writeSpeedLimit
Write speed limit in bytes per second.
virtual ~BandwidthBucket()
BandwidthBucket(const int speed, const int initialLevelPercent, const double sizeLimit)
Details about a particular Comm IO callback event.
Definition: IoCallback.h:30
virtual void reduceBucket(const int len)
Decreases the bucket level.
virtual bool applyQuota(int &nleft, Comm::IoCallback *state)
virtual int quota()=0
Base class for Squid-to-client bandwidth limiting.
double bucketSizeLimit
maximum bucket size
virtual void onFdClosed()
Performs cleanup when the related file descriptor becomes closed.
static BandwidthBucket * SelectBucket(fde *f)
double prevTime
previous time when we checked
void refillBucket()
Increases the bucket level with the writeSpeedLimit speed.
double bucketLevel
how much can be written now
bool selectWaiting
is between commSetSelect and commHandleWrite

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors