]> git.ipfire.org Git - thirdparty/squid.git/blob - src/DelayVector.cc
Cleanup: zap CVS Id tags
[thirdparty/squid.git] / src / DelayVector.cc
1
2 /*
3 * $Id$
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 #include "CommRead.h"
46
47 void *
48 DelayVector::operator new(size_t size)
49 {
50 DelayPools::MemoryUsed += sizeof (DelayVector);
51 return ::operator new (size);
52 }
53
54 void
55 DelayVector::operator delete (void *address)
56 {
57 DelayPools::MemoryUsed -= sizeof (DelayVector);
58 ::operator delete (address);
59 }
60
61 DelayVector::DelayVector()
62 {
63 DelayPools::registerForUpdates (this);
64 }
65
66 DelayVector::~DelayVector()
67 {
68 DelayPools::deregisterForUpdates (this);
69 }
70
71 void
72 DelayVector::stats(StoreEntry * sentry)
73 {
74 iterator pos = pools.begin();
75
76 while (pos != pools.end()) {
77 (*pos)->stats(sentry);
78 ++pos;
79 }
80 }
81
82 void
83 DelayVector::dump(StoreEntry *entry) const
84 {
85 const_iterator pos = pools.begin();
86
87 while (pos != pools.end()) {
88 (*pos)->dump(entry);
89 ++pos;
90 }
91 }
92
93 void
94 DelayVector::update(int incr)
95 {
96 /*
97 * Each pool updates itself,
98 * but we may have deferred reads waiting on the pool as a whole.
99 */
100
101 kickReads();
102 }
103
104 void
105 DelayVector::parse()
106 {
107 iterator pos = pools.begin();
108
109 while (pos != pools.end()) {
110 (*pos)->parse();
111 ++pos;
112 }
113 }
114
115 DelayIdComposite::Pointer
116 DelayVector::id(CompositeSelectionDetails &details)
117 {
118 return new Id(this, details);
119 }
120
121 void
122 DelayVector::push_back(CompositePoolNode::Pointer aNode)
123 {
124 pools.push_back(aNode);
125 }
126
127 void *
128 DelayVector::Id::operator new(size_t size)
129 {
130 DelayPools::MemoryUsed += sizeof (Id);
131 return ::operator new (size);
132 }
133
134 void
135 DelayVector::Id::operator delete (void *address)
136 {
137 DelayPools::MemoryUsed -= sizeof (Id);
138 ::operator delete (address);
139 }
140
141 DelayVector::Id::Id(DelayVector::Pointer aDelayVector, CompositeSelectionDetails &details) : theVector(aDelayVector)
142 {
143 debugs(77, 3, "DelayVector::Id::Id");
144 DelayVector::iterator pos = theVector->pools.begin();
145
146 while (pos != theVector->pools.end()) {
147 ids.push_back ((*pos)->id (details));
148 ++pos;
149 }
150 }
151
152 DelayVector::Id::~Id()
153 {
154 debugs(77, 3, "DelayVector::Id::~Id");
155 }
156
157 int
158 DelayVector::Id::bytesWanted (int minimum, int maximum) const
159 {
160 int nbytes = maximum;
161 const_iterator pos = ids.begin();
162
163 while (pos != ids.end()) {
164 nbytes = min (nbytes, (*pos)->bytesWanted(minimum, nbytes));
165 ++pos;
166 }
167
168 nbytes = max(minimum, nbytes);
169 return nbytes;
170 }
171
172 void
173 DelayVector::Id::bytesIn(int qty)
174 {
175 iterator pos = ids.begin();
176
177 while (pos != ids.end()) {
178 (*pos)->bytesIn(qty);
179 ++pos;
180 }
181
182 theVector->kickReads();
183 }
184
185 void
186 DelayVector::Id::delayRead(DeferredRead const &aRead)
187 {
188 theVector->delayRead(aRead);
189 }
190
191 #endif