source: squid-ssl/trunk/fuentes/src/DelayBucket.cc @ 5495

Last change on this file since 5495 was 5495, checked in by Juanma, 2 years ago

Initial release

File size: 1.1 KB
Line 
1/*
2 * Copyright (C) 1996-2015 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/* DEBUG: section 77    Delay Pools */
10
11#include "squid.h"
12
13#if USE_DELAY_POOLS
14#include "DelayBucket.h"
15#include "DelaySpec.h"
16#include "SquidConfig.h"
17#include "Store.h"
18
19void
20DelayBucket::stats(StoreEntry *entry)const
21{
22    storeAppendPrintf(entry, "%d", level());
23}
24
25void
26DelayBucket::update(DelaySpec const &rate, int incr)
27{
28    if (rate.restore_bps != -1 &&
29            (level() += rate.restore_bps * incr) > rate.max_bytes)
30        level() = rate.max_bytes;
31}
32
33int
34DelayBucket::bytesWanted(int minimum, int maximum) const
35{
36    int result = max(minimum, min(maximum, level()));
37    return result;
38}
39
40void
41DelayBucket::bytesIn(int qty)
42{
43    level() -= qty;
44}
45
46void
47DelayBucket::init(DelaySpec const &rate)
48{
49    level() = (int) (((double)rate.max_bytes *
50                      Config.Delay.initial) / 100);
51}
52
53#endif /* USE_DELAY_POOLS */
54
Note: See TracBrowser for help on using the repository browser.