]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/base/AsyncCall.cc
6 #include "base/AsyncCall.h"
7 #include "base/AsyncCallQueue.h"
12 InstanceIdDefinitions(AsyncCall
, "call");
16 AsyncCall::AsyncCall(int aDebugSection
, int aDebugLevel
,
17 const char *aName
): name(aName
), debugSection(aDebugSection
),
18 debugLevel(aDebugLevel
), theNext(0), isCanceled(NULL
)
20 debugs(debugSection
, debugLevel
, "The AsyncCall " << name
<< " constructed, this=" << this <<
24 AsyncCall::~AsyncCall()
26 assert(!theNext
); // AsyncCallQueue must clean
32 debugs(debugSection
, debugLevel
, HERE
<< "make call " << name
<<
39 if (!isCanceled
) // we did not cancel() when returning false from canFire()
40 isCanceled
= "unknown reason";
42 debugs(debugSection
, debugLevel
, HERE
<< "will not call " << name
<<
43 " [" << id
<< ']' << " because of " << isCanceled
);
47 AsyncCall::cancel(const char *reason
)
49 debugs(debugSection
, debugLevel
, HERE
<< "will not call " << name
<<
50 " [" << id
<< "] " << (isCanceled
? "also " : "") <<
51 "because " << reason
);
63 /// \todo make this method const by providing a const getDialer()
65 AsyncCall::print(std::ostream
&os
)
68 if (const CallDialer
*dialer
= getDialer())
71 os
<< "(?" << this << "?)";
75 AsyncCall::dequeue(AsyncCall::Pointer
&head
, AsyncCall::Pointer
&prev
)
78 prev
->setNext(Next());
85 ScheduleCall(const char *fileName
, int fileLine
, AsyncCall::Pointer
&call
)
87 debugs(call
->debugSection
, call
->debugLevel
, fileName
<< "(" << fileLine
<<
88 ") will call " << *call
<< " [" << call
->id
<< ']' );
89 AsyncCallQueue::Instance().schedule(call
);