24#include <unordered_set>
32 static const auto jobs =
new std::unordered_set<AsyncJob *, std::hash<AsyncJob *>, std::equal_to<AsyncJob *>,
PoolingAllocator<AsyncJob *> >();
44 stopReason(nullptr), typeName(aTypeName), inCall(nullptr)
46 debugs(93,5,
"AsyncJob constructed, this=" <<
this <<
47 " type=" <<
typeName <<
" [" <<
id <<
']');
53 debugs(93,5,
"AsyncJob destructed, this=" <<
this <<
54 " type=" <<
typeName <<
" [" <<
id <<
']');
102 debugs(93, 5,
typeName <<
" will stop, another reason: " << aReason);
123 call <<
" cannot reenter the job.");
124 return call.
cancel(
"reentrant job call");
158 void *thisSaved =
this;
172 debugs(93, 6, *inCallSaved <<
" ended " << thisSaved);
191 buf.
appendf(
" %s%u]",
id.prefix(),
id.value);
202 const char *indent =
" ";
203 for (
const auto job:
AllJobs()) {
204 os << indent << job->id <<
":\n";
205 os << indent << indent <<
"type: '" << job->typeName <<
"'\n";
206 os << indent << indent <<
"status:" << job->status() <<
'\n';
208 os << indent << indent <<
"started: false\n";
210 os << indent << indent <<
"stopped: '" << job->stopReason <<
"'\n";
RefCount< AsyncCallT< Dialer > > asyncCall(int aDebugSection, int aDebugLevel, const char *aName, const Dialer &aDialer)
NullaryMemFunT< C > JobMemFun(const CbcPointer< C > &job, typename NullaryMemFunT< C >::Method method)
#define CallJobHere(debugSection, debugLevel, job, Class, method)
static auto & AllJobs()
a set of all AsyncJob objects in existence
#define InstanceIdDefinitions(...)
convenience macro to instantiate Class-specific stuff in .cc files
int cbdataReferenceValid(const void *p)
bool cancel(const char *reason)
static void Start(const Pointer &job)
virtual bool doneAll() const
whether positive goal has been reached
virtual void start()
called by AsyncStart; do not call directly
static void RegisterWithCacheManager()
AsyncJob(const char *aTypeName)
bool swanSang_
swanSong() was called
virtual void callEnd()
called right after the called job method
void mustStop(const char *aReason)
static void ReportAllJobs(StoreEntry *)
writes a cache manager report about all jobs existing in this worker
const char * typeName
kid (leaf) class name, for debugging
bool started_
Start() has finished successfully.
void deleteThis(const char *aReason)
void callStart(AsyncCall &call)
bool done() const
the job is destroyed in callEnd() when done()
AsyncCall::Pointer inCall
the asynchronous call being handled, if any
virtual const char * status() const
internal cleanup; do not call directly
bool canBeCalled(AsyncCall &call) const
whether we can be called
virtual void callException(const std::exception &e)
called when the job throws during an async call
const char * stopReason
reason for forcing done() to be true
virtual void * toCbdata()=0
void append(const char *c, int sz) override
char * content()
start of the added data
void appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
Append operation with printf-style arguments.
STL Allocator that uses Squid memory pools for memory management.
#define debugs(SECTION, LEVEL, CONTENT)
void RegisterAction(char const *action, char const *desc, OBJH *handler, Protected, Atomic, Format)