]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/base/AsyncCall.cc
a40fc1e21a91b5b8af5832240e82fcbedd666cc4
2 * Copyright (C) 1996-2020 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.
10 #include "base/AsyncCall.h"
11 #include "base/AsyncCallQueue.h"
12 #include "base/CodeContext.h"
17 InstanceIdDefinitions(AsyncCall
, "call");
21 AsyncCall::AsyncCall(int aDebugSection
, int aDebugLevel
, const char *aName
):
23 codeContext(CodeContext::Current()),
24 debugSection(aDebugSection
),
25 debugLevel(aDebugLevel
),
29 debugs(debugSection
, debugLevel
, "The AsyncCall " << name
<< " constructed, this=" << this <<
33 AsyncCall::~AsyncCall()
35 assert(!theNext
); // AsyncCallQueue must clean
41 debugs(debugSection
, debugLevel
, HERE
<< "make call " << name
<<
48 if (!isCanceled
) // we did not cancel() when returning false from canFire()
49 isCanceled
= "unknown reason";
51 debugs(debugSection
, debugLevel
, HERE
<< "will not call " << name
<<
52 " [" << id
<< ']' << " because of " << isCanceled
);
56 AsyncCall::cancel(const char *reason
)
58 debugs(debugSection
, debugLevel
, HERE
<< "will not call " << name
<<
59 " [" << id
<< "] " << (isCanceled
? "also " : "") <<
60 "because " << reason
);
72 // TODO: make this method const by providing a const getDialer()
74 AsyncCall::print(std::ostream
&os
)
77 if (const CallDialer
*dialer
= getDialer())
80 os
<< "(?" << this << "?)";
84 AsyncCall::dequeue(AsyncCall::Pointer
&head
, AsyncCall::Pointer
&prev
)
87 prev
->setNext(Next());
94 ScheduleCall(const char *fileName
, int fileLine
, AsyncCall::Pointer
&call
)
96 debugs(call
->debugSection
, call
->debugLevel
, fileName
<< "(" << fileLine
<<
97 ") will call " << *call
<< " [" << call
->id
<< ']' );
99 // Support callback creators that did not get their context from service A,
100 // but the current caller (service B) got that context from another source.
101 if (!call
->codeContext
)
102 call
->codeContext
= CodeContext::Current();
104 AsyncCallQueue::Instance().schedule(call
);