BandwidthBucket.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 
Base class for Squid-to-client bandwidth limiting.
virtual void reduceBucket(const int len)
Decreases the bucket level.
virtual void onFdClosed()
Performs cleanup when the related file descriptor becomes closed.
double prevTime
previous time when we checked
virtual ~BandwidthBucket()
virtual void scheduleWrite(Comm::IoCallback *state)=0
Will plan another write call.
BandwidthBucket(const int speed, const int initialLevelPercent, const double sizeLimit)
bool selectWaiting
is between commSetSelect and commHandleWrite
void refillBucket()
Increases the bucket level with the writeSpeedLimit speed.
double writeSpeedLimit
Write speed limit in bytes per second.
double bucketSizeLimit
maximum bucket size
bool noLimit() const
Whether this bucket will not do bandwidth limiting.
double bucketLevel
how much can be written now
static BandwidthBucket * SelectBucket(fde *f)
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
virtual bool applyQuota(int &nleft, Comm::IoCallback *state)
Definition: fde.h:49
virtual int quota()=0
Details about a particular Comm IO callback event.
Definition: IoCallback.h:29

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors