2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 77 Delay Pools */
14 #include "comm/Connection.h"
16 #include "DelayVector.h"
19 DelayVector::operator new(size_t size
)
21 DelayPools::MemoryUsed
+= sizeof (DelayVector
);
22 return ::operator new (size
);
26 DelayVector::operator delete (void *address
)
28 DelayPools::MemoryUsed
-= sizeof (DelayVector
);
29 ::operator delete (address
);
32 DelayVector::DelayVector()
34 DelayPools::registerForUpdates (this);
37 DelayVector::~DelayVector()
39 DelayPools::deregisterForUpdates (this);
43 DelayVector::stats(StoreEntry
* sentry
)
45 iterator pos
= pools
.begin();
47 while (pos
!= pools
.end()) {
48 (*pos
)->stats(sentry
);
54 DelayVector::dump(StoreEntry
*entry
) const
56 const_iterator pos
= pools
.begin();
58 while (pos
!= pools
.end()) {
65 DelayVector::update(int incr
)
68 * Each pool updates itself,
69 * but we may have deferred reads waiting on the pool as a whole.
78 iterator pos
= pools
.begin();
80 while (pos
!= pools
.end()) {
86 DelayIdComposite::Pointer
87 DelayVector::id(CompositeSelectionDetails
&details
)
89 return new Id(this, details
);
93 DelayVector::push_back(CompositePoolNode::Pointer aNode
)
95 pools
.push_back(aNode
);
99 DelayVector::Id::operator new(size_t size
)
101 DelayPools::MemoryUsed
+= sizeof (Id
);
102 return ::operator new (size
);
106 DelayVector::Id::operator delete (void *address
)
108 DelayPools::MemoryUsed
-= sizeof (Id
);
109 ::operator delete (address
);
112 DelayVector::Id::Id(DelayVector::Pointer aDelayVector
, CompositeSelectionDetails
&details
) : theVector(aDelayVector
)
114 debugs(77, 3, "DelayVector::Id::Id");
115 DelayVector::iterator pos
= theVector
->pools
.begin();
117 while (pos
!= theVector
->pools
.end()) {
118 ids
.push_back ((*pos
)->id (details
));
123 DelayVector::Id::~Id()
125 debugs(77, 3, "DelayVector::Id::~Id");
129 DelayVector::Id::bytesWanted (int minimum
, int maximum
) const
131 int nbytes
= maximum
;
132 const_iterator pos
= ids
.begin();
134 while (pos
!= ids
.end()) {
135 nbytes
= min (nbytes
, (*pos
)->bytesWanted(minimum
, nbytes
));
139 nbytes
= max(minimum
, nbytes
);
144 DelayVector::Id::bytesIn(int qty
)
146 iterator pos
= ids
.begin();
148 while (pos
!= ids
.end()) {
149 (*pos
)->bytesIn(qty
);
153 theVector
->kickReads();
157 DelayVector::Id::delayRead(DeferredRead
const &aRead
)
159 theVector
->delayRead(aRead
);