]> git.ipfire.org Git - thirdparty/squid.git/blob - src/DelayVector.cc
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / DelayVector.cc
1 /*
2 * Copyright (C) 1996-2021 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 "comm/Connection.h"
15 #include "CommRead.h"
16 #include "DelayVector.h"
17
18 DelayVector::DelayVector()
19 {
20 DelayPools::registerForUpdates (this);
21 }
22
23 DelayVector::~DelayVector()
24 {
25 DelayPools::deregisterForUpdates (this);
26 }
27
28 void
29 DelayVector::stats(StoreEntry * sentry)
30 {
31 iterator pos = pools.begin();
32
33 while (pos != pools.end()) {
34 (*pos)->stats(sentry);
35 ++pos;
36 }
37 }
38
39 void
40 DelayVector::dump(StoreEntry *entry) const
41 {
42 const_iterator pos = pools.begin();
43
44 while (pos != pools.end()) {
45 (*pos)->dump(entry);
46 ++pos;
47 }
48 }
49
50 void
51 DelayVector::update(int incr)
52 {
53 /*
54 * Each pool updates itself,
55 * but we may have deferred reads waiting on the pool as a whole.
56 */
57
58 kickReads();
59 }
60
61 void
62 DelayVector::parse()
63 {
64 iterator pos = pools.begin();
65
66 while (pos != pools.end()) {
67 (*pos)->parse();
68 ++pos;
69 }
70 }
71
72 DelayIdComposite::Pointer
73 DelayVector::id(CompositeSelectionDetails &details)
74 {
75 return new Id(this, details);
76 }
77
78 void
79 DelayVector::push_back(CompositePoolNode::Pointer aNode)
80 {
81 pools.push_back(aNode);
82 }
83
84 DelayVector::Id::Id(DelayVector::Pointer aDelayVector, CompositeSelectionDetails &details) : theVector(aDelayVector)
85 {
86 debugs(77, 3, "DelayVector::Id::Id");
87 DelayVector::iterator pos = theVector->pools.begin();
88
89 while (pos != theVector->pools.end()) {
90 ids.push_back ((*pos)->id (details));
91 ++pos;
92 }
93 }
94
95 DelayVector::Id::~Id()
96 {
97 debugs(77, 3, "DelayVector::Id::~Id");
98 }
99
100 int
101 DelayVector::Id::bytesWanted (int minimum, int maximum) const
102 {
103 int nbytes = maximum;
104 const_iterator pos = ids.begin();
105
106 while (pos != ids.end()) {
107 nbytes = min (nbytes, (*pos)->bytesWanted(minimum, nbytes));
108 ++pos;
109 }
110
111 nbytes = max(minimum, nbytes);
112 return nbytes;
113 }
114
115 void
116 DelayVector::Id::bytesIn(int qty)
117 {
118 iterator pos = ids.begin();
119
120 while (pos != ids.end()) {
121 (*pos)->bytesIn(qty);
122 ++pos;
123 }
124
125 theVector->kickReads();
126 }
127
128 void
129 DelayVector::Id::delayRead(DeferredRead const &aRead)
130 {
131 theVector->delayRead(aRead);
132 }
133
134 #endif
135