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

 

Introduction

Documentation

Support

Miscellaneous