BandwidthBucket.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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
16class fde;
17
20{
21public:
22 BandwidthBucket(const int speed, const int initialLevelPercent, const double sizeLimit);
23 virtual ~BandwidthBucket() {}
24
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
43protected:
45 void refillBucket();
46
47public:
48 double bucketLevel;
50
51protected:
52 double prevTime;
55};
56
57#endif /* USE_DELAY_POOLS */
58
59#endif
60
Base class for Squid-to-client bandwidth limiting.
bool noLimit() const
Whether this bucket will not do bandwidth limiting.
double bucketLevel
how much can be written now
void refillBucket()
Increases the bucket level with the writeSpeedLimit speed.
double bucketSizeLimit
maximum bucket size
virtual ~BandwidthBucket()
BandwidthBucket(const int speed, const int initialLevelPercent, const double sizeLimit)
virtual void onFdClosed()
Performs cleanup when the related file descriptor becomes closed.
double prevTime
previous time when we checked
virtual bool applyQuota(int &nleft, Comm::IoCallback *state)
virtual int quota()=0
double writeSpeedLimit
Write speed limit in bytes per second.
static BandwidthBucket * SelectBucket(fde *f)
virtual void reduceBucket(const int len)
Decreases the bucket level.
bool selectWaiting
is between commSetSelect and commHandleWrite
virtual void scheduleWrite(Comm::IoCallback *state)=0
Will plan another write call.
Details about a particular Comm IO callback event.
Definition: IoCallback.h:30
Definition: fde.h:52

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors