]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/base/AsyncCallQueue.cc
2 * Copyright (C) 1996-2021 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 41 Event Processing */
12 #include "base/AsyncCall.h"
13 #include "base/AsyncCallQueue.h"
16 AsyncCallQueue
*AsyncCallQueue::TheInstance
= 0;
18 AsyncCallQueue::AsyncCallQueue(): theHead(NULL
), theTail(NULL
)
22 void AsyncCallQueue::schedule(AsyncCall::Pointer
&call
)
25 assert(!call
->theNext
);
26 if (theHead
!= NULL
) { // append
27 assert(!theTail
->theNext
);
28 theTail
->theNext
= call
;
30 } else { // create queue from cratch
31 theHead
= theTail
= call
;
35 // Fire all scheduled calls; returns true if at least one call was fired.
36 // The calls may be added while the current call is in progress.
38 AsyncCallQueue::fire()
40 const bool made
= theHead
!= NULL
;
42 CodeContext::Reset(theHead
->codeContext
);
51 AsyncCallQueue::fireNext()
53 AsyncCall::Pointer call
= theHead
;
54 theHead
= call
->theNext
;
59 debugs(call
->debugSection
, call
->debugLevel
, "entering " << *call
);
61 debugs(call
->debugSection
, call
->debugLevel
, "leaving " << *call
);
65 AsyncCallQueue::Instance()
67 // TODO: how to remove this frequent check while supporting early calls?
69 TheInstance
= new AsyncCallQueue();