DelayId::DelayId () : pool_ (0), compositeId(nullptr), markedAsNoDelay(false)
{}
-DelayId::DelayId (unsigned short aPool) :
- pool_ (aPool), compositeId (nullptr), markedAsNoDelay (false)
+DelayId::DelayId(const unsigned short aPool, const DelayIdComposite::Pointer &aCompositeId):
+ pool_(aPool), compositeId(aCompositeId), markedAsNoDelay(false)
{
+ assert(pool_);
+ assert(compositeId);
debugs(77, 3, "DelayId::DelayId: Pool " << aPool << "u");
}
DelayId::~DelayId ()
{}
-void
-DelayId::compositePosition(const DelayIdComposite::Pointer &newPosition)
-{
- compositeId = newPosition;
-}
-
unsigned short
DelayId::pool() const
{
DelayId::operator bool() const
{
- return (pool_ || compositeId.getRaw()) && !markedAsNoDelay;
+ return compositeId && !markedAsNoDelay;
}
/* create a delay Id for a given request */
ch.src_addr = r->client_addr;
if (DelayPools::delay_data[pool].theComposite().getRaw() && ch.fastCheck().allowed()) {
-
- DelayId result (pool + 1);
CompositePoolNode::CompositeSelectionDetails details(ch.src_addr, StringToSBuf(r->tag));
#if USE_AUTH
details.user = r->auth_user_request;
#endif
- result.compositePosition(DelayPools::delay_data[pool].theComposite()->id(details));
- return result;
+ return DelayId(pool + 1, DelayPools::delay_data[pool].theComposite()->id(details));
}
}
int
DelayId::bytesWanted(int minimum, int maximum) const
{
- /* unlimited */
+ const auto maxBytes = max(minimum, maximum);
if (! (*this))
- return max(minimum, maximum);
-
- /* limited */
- int nbytes = max(minimum, maximum);
+ return maxBytes;
- if (compositeId != nullptr)
- nbytes = compositeId->bytesWanted(minimum, nbytes);
-
- return nbytes;
+ return compositeId->bytesWanted(minimum, maxBytes);
}
/*
if (! (*this))
return;
- assert ((unsigned short)(pool() - 1) != 0xFFFF);
-
- if (compositeId != nullptr)
- compositeId->bytesIn(qty);
+ compositeId->bytesIn(qty);
}
void
public:
static DelayId DelayClient(ClientHttpRequest *, HttpReply *reply = nullptr);
DelayId ();
- DelayId (unsigned short);
+ DelayId(unsigned short, const DelayIdComposite::Pointer &);
~DelayId ();
unsigned short pool() const;
- DelayIdComposite::Pointer compositePosition();
- DelayIdComposite::Pointer const compositePosition() const;
- void compositePosition(const DelayIdComposite::Pointer &);
bool operator == (DelayId const &rhs) const;
/// Whether we may delay reading. This operator is meant to be used as an