]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/DelayBucket.cc
2 * $Id: DelayBucket.cc,v 1.8 2008/02/26 21:49:34 amosjeffries Exp $
4 * DEBUG: section 77 Delay Pools
5 * AUTHOR: Robert Collins <robertc@squid-cache.org>
6 * Based upon original delay pools code by
7 * David Luyer <david@luyer.net>
9 * SQUID Web Proxy Cache http://www.squid-cache.org/
10 * ----------------------------------------------------------
12 * Squid is the result of efforts by numerous individuals from
13 * the Internet community; see the CONTRIBUTORS file for full
14 * details. Many organizations have provided support for Squid's
15 * development; see the SPONSORS file for full details. Squid is
16 * Copyrighted (C) 2001 by the Regents of the University of
17 * California; see the COPYRIGHT file for full details. Squid
18 * incorporates software developed and/or copyrighted by other
19 * sources; see the CREDITS file for full details.
21 * This program is free software; you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation; either version 2 of the License, or
24 * (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
36 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
43 #include "DelayBucket.h"
44 #include "DelaySpec.h"
48 #include "DelayPools.h"
49 #include "StoreClient.h"
50 #include "MemObject.h"
51 #include "client_side_request.h"
52 #include "ACLChecklist.h"
54 #include "ConfigParser.h"
58 #include "CommonPool.h"
59 #include "CompositePoolNode.h"
60 #include "DelayPool.h"
61 #include "DelayVector.h"
62 #include "NullDelayId.h"
66 DelayBucket::stats(StoreEntry
*entry
)const
68 storeAppendPrintf(entry
, "%d", level());
72 DelayBucket::update(DelaySpec
const &rate
, int incr
)
74 if (rate
.restore_bps
!= -1 &&
75 (level() += rate
.restore_bps
* incr
) > rate
.max_bytes
)
76 level() = rate
.max_bytes
;
80 DelayBucket::bytesWanted(int minimum
, int maximum
) const
82 int result
= max(minimum
, min(maximum
, level()));
87 DelayBucket::bytesIn(int qty
)
93 DelayBucket::init(DelaySpec
const &rate
)
95 level() = (int) (((double)rate
.max_bytes
*
96 Config
.Delay
.initial
) / 100);