DelayVector.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2022 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
virtual void update(int incr)
Definition: DelayVector.cc:52
static void deregisterForUpdates(Updateable *)
Definition: delay_pools.cc:515
Id(RefCount< DelayVector >, CompositeSelectionDetails &)
Definition: DelayVector.cc:85
A const & max(A const &lhs, A const &rhs)
std::vector< CompositePoolNode::Pointer > pools
Definition: DelayVector.h:57
std::vector< DelayIdComposite::Pointer >::const_iterator const_iterator
Definition: DelayVector.h:52
std::vector< CompositePoolNode::Pointer >::const_iterator const_iterator
Definition: DelayVector.h:59
virtual void stats(StoreEntry *sentry)
Definition: DelayVector.cc:30
virtual void parse()
Definition: DelayVector.cc:63
static void registerForUpdates(Updateable *)
Definition: delay_pools.cc:508
virtual void bytesIn(int qty)
Definition: DelayVector.cc:117
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
friend class Id
Definition: DelayVector.h:55
virtual DelayIdComposite::Pointer id(CompositeSelectionDetails &)
Definition: DelayVector.cc:74
virtual void dump(StoreEntry *entry) const
Definition: DelayVector.cc:41
A const & min(A const &lhs, A const &rhs)
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:196
virtual int bytesWanted(int min, int max) const
Definition: DelayVector.cc:102
virtual void delayRead(const AsyncCallPointer &)
Definition: DelayVector.cc:130
virtual ~DelayVector()
Definition: DelayVector.cc:24
std::vector< DelayIdComposite::Pointer > ids
Definition: DelayVector.h:50

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors