]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/base/AsyncCallQueue.cc
2 * Copyright (C) 1996-2014 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
;
41 while (theHead
!= NULL
)
47 AsyncCallQueue::fireNext()
49 AsyncCall::Pointer call
= theHead
;
50 theHead
= call
->theNext
;
55 debugs(call
->debugSection
, call
->debugLevel
, "entering " << *call
);
57 debugs(call
->debugSection
, call
->debugLevel
, "leaving " << *call
);
61 AsyncCallQueue::Instance()
63 // TODO: how to remove this frequent check while supporting early calls?
65 TheInstance
= new AsyncCallQueue();