]> git.ipfire.org Git - thirdparty/squid.git/blob - src/DelayVector.cc
Summary: Merge delay-class-4 fixes into HEAD.
[thirdparty/squid.git] / src / DelayVector.cc
1
2 /*
3 * $Id: DelayVector.cc,v 1.2 2003/02/06 09:57:36 robertc Exp $
4 *
5 * DEBUG: section 77 Delay Pools
6 * AUTHOR: Robert Collins <robertc@squid-cache.org>
7 * Based upon original delay pools code by
8 * David Luyer <david@luyer.net>
9 *
10 * SQUID Web Proxy Cache http://www.squid-cache.org/
11 * ----------------------------------------------------------
12 *
13 * Squid is the result of efforts by numerous individuals from
14 * the Internet community; see the CONTRIBUTORS file for full
15 * details. Many organizations have provided support for Squid's
16 * development; see the SPONSORS file for full details. Squid is
17 * Copyrighted (C) 2001 by the Regents of the University of
18 * California; see the COPYRIGHT file for full details. Squid
19 * incorporates software developed and/or copyrighted by other
20 * sources; see the CREDITS file for full details.
21 *
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 2 of the License, or
25 * (at your option) any later version.
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
35 *
36 *
37 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
38 */
39
40 #include "config.h"
41
42 #if DELAY_POOLS
43 #include "squid.h"
44 #include "DelayVector.h"
45
46 void *
47 DelayVector::operator new(size_t size)
48 {
49 DelayPools::MemoryUsed += sizeof (DelayVector);
50 return ::operator new (size);
51 }
52
53 void
54 DelayVector::operator delete (void *address)
55 {
56 DelayPools::MemoryUsed -= sizeof (DelayVector);
57 ::operator delete (address);
58 }
59
60 void
61 DelayVector::deleteSelf() const
62 {
63 delete this;
64 }
65
66 DelayVector::~DelayVector()
67 {
68 }
69
70 void
71 DelayVector::stats(StoreEntry * sentry)
72 {
73 iterator pos = pools.begin();
74 while (pos != pools.end()) {
75 (*pos)->stats(sentry);
76 ++pos;
77 }
78 }
79
80 void
81 DelayVector::dump(StoreEntry *entry) const
82 {
83 const_iterator pos = pools.begin();
84 while (pos != pools.end()) {
85 (*pos)->dump(entry);
86 ++pos;
87 }
88 }
89
90 void
91 DelayVector::update(int incr)
92 {
93 iterator pos = pools.begin();
94 while (pos != pools.end()) {
95 (*pos)->update(incr);
96 ++pos;
97 }
98 }
99
100 void
101 DelayVector::parse()
102 {
103 iterator pos = pools.begin();
104 while (pos != pools.end()) {
105 (*pos)->parse();
106 ++pos;
107 }
108 }
109
110 DelayIdComposite::Pointer
111 DelayVector::id(struct in_addr &src_addr, AuthUserRequest *authUser)
112 {
113 return new Id(this, src_addr, authUser);
114 }
115
116 void
117 DelayVector::push_back(CompositePoolNode::Pointer aNode)
118 {
119 pools.push_back(aNode);
120 }
121
122 void *
123 DelayVector::Id::operator new(size_t size)
124 {
125 DelayPools::MemoryUsed += sizeof (Id);
126 return ::operator new (size);
127 }
128
129 void
130 DelayVector::Id::operator delete (void *address)
131 {
132 DelayPools::MemoryUsed -= sizeof (Id);
133 ::operator delete (address);
134 }
135
136 void
137 DelayVector::Id::deleteSelf() const
138 {
139 delete this;
140 }
141
142 DelayVector::Id::Id(DelayVector::Pointer aDelayVector,struct in_addr &src_addr, AuthUserRequest *authUser) : theVector(aDelayVector)
143 {
144 debug(77,3)("DelayVector::Id::Id\n");
145 DelayVector::iterator pos = theVector->pools.begin();
146 while (pos != theVector->pools.end()) {
147 ids.push_back ((*pos)->id (src_addr, authUser));
148 ++pos;
149 }
150 }
151
152 DelayVector::Id::~Id()
153 {
154 debug(77,3)("DelayVector::Id::~Id\n");
155 }
156
157 int
158 DelayVector::Id::bytesWanted (int min, int max) const
159 {
160 int nbytes = max;
161 const_iterator pos = ids.begin();
162 while (pos != ids.end()) {
163 nbytes = XMIN (nbytes, (*pos)->bytesWanted(min, nbytes));
164 ++pos;
165 }
166 nbytes = XMAX(min, nbytes);
167 return nbytes;
168 }
169
170 void
171 DelayVector::Id::bytesIn(int qty)
172 {
173 iterator pos = ids.begin();
174 while (pos != ids.end()) {
175 (*pos)->bytesIn(qty);
176 ++pos;
177 }
178 }
179 #endif