]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/base/AsyncCall.cc
2 * Copyright (C) 1996-2018 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 "AsyncCall.h"
11 #include "base/AsyncCall.h"
12 #include "base/AsyncCallQueue.h"
17 InstanceIdDefinitions(AsyncCall
, "call");
21 AsyncCall::AsyncCall(int aDebugSection
, int aDebugLevel
,
22 const char *aName
): name(aName
), debugSection(aDebugSection
),
23 debugLevel(aDebugLevel
), theNext(0), isCanceled(NULL
)
25 debugs(debugSection
, debugLevel
, "The AsyncCall " << name
<< " constructed, this=" << this <<
29 AsyncCall::~AsyncCall()
31 assert(!theNext
); // AsyncCallQueue must clean
37 debugs(debugSection
, debugLevel
, HERE
<< "make call " << name
<<
44 if (!isCanceled
) // we did not cancel() when returning false from canFire()
45 isCanceled
= "unknown reason";
47 debugs(debugSection
, debugLevel
, HERE
<< "will not call " << name
<<
48 " [" << id
<< ']' << " because of " << isCanceled
);
52 AsyncCall::cancel(const char *reason
)
54 debugs(debugSection
, debugLevel
, HERE
<< "will not call " << name
<<
55 " [" << id
<< "] " << (isCanceled
? "also " : "") <<
56 "because " << reason
);
68 /// \todo make this method const by providing a const getDialer()
70 AsyncCall::print(std::ostream
&os
)
73 if (const CallDialer
*dialer
= getDialer())
76 os
<< "(?" << this << "?)";
80 AsyncCall::dequeue(AsyncCall::Pointer
&head
, AsyncCall::Pointer
&prev
)
83 prev
->setNext(Next());
90 ScheduleCall(const char *fileName
, int fileLine
, AsyncCall::Pointer
&call
)
92 debugs(call
->debugSection
, call
->debugLevel
, fileName
<< "(" << fileLine
<<
93 ") will call " << *call
<< " [" << call
->id
<< ']' );
94 AsyncCallQueue::Instance().schedule(call
);