buf.append(" A.", 3);
}
- buf.Printf(" ecapx%d]", id);
+ buf.Printf(" %s%u]", id.Prefix, id.value);
buf.terminate();
buf.append("/", 1);
fillDoneStatus(buf);
- buf.Printf(" icapx%d]", id);
+ buf.Printf(" %s%u]", id.Prefix, id.value);
buf.terminate();
#include "base/AsyncCallQueue.h"
#include "cbdata.h"
-unsigned int AsyncCall::TheLastId = 0;
+InstanceIdDefinitions(AsyncCall, "call");
/* AsyncCall */
AsyncCall::AsyncCall(int aDebugSection, int aDebugLevel,
const char *aName): name(aName), debugSection(aDebugSection),
- debugLevel(aDebugLevel), id(++TheLastId), theNext(0), isCanceled(NULL)
+ debugLevel(aDebugLevel), theNext(0), isCanceled(NULL)
{
debugs(debugSection, debugLevel, "The AsyncCall " << name << " constructed, this=" << this <<
- " [call" << id << ']');
+ " [" << id << ']');
}
AsyncCall::~AsyncCall()
AsyncCall::make()
{
debugs(debugSection, debugLevel, HERE << "make call " << name <<
- " [call"<< id << ']');
+ " [" << id << ']');
if (canFire()) {
fire();
return;
isCanceled = "unknown reason";
debugs(debugSection, debugLevel, HERE << "will not call " << name <<
- " [call"<< id << ']' << " because of " << isCanceled);
+ " [" << id << ']' << " because of " << isCanceled);
}
bool
{
if (isCanceled)
debugs(debugSection, debugLevel, HERE << "will not call " << name <<
- " [call"<< id << ']' << " also because " << reason);
+ " [" << id << ']' << " also because " << reason);
isCanceled = reason;
return false;
}
ScheduleCall(const char *fileName, int fileLine, AsyncCall::Pointer &call)
{
debugs(call->debugSection, call->debugLevel, fileName << "(" << fileLine <<
- ") will call " << *call << " [call"<< call->id << ']' );
+ ") will call " << *call << " [" << call->id << ']' );
AsyncCallQueue::Instance().schedule(call);
return true;
}
#define SQUID_ASYNCCALL_H
//#include "cbdata.h"
+#include "base/InstanceId.h"
#include "event.h"
//#include "TextException.h"
const char *const name;
const int debugSection;
const int debugLevel;
- const unsigned int id;
+ const InstanceId<AsyncCall> id;
protected:
virtual bool canFire();
private:
const char *isCanceled; // set to the cancelation reason by cancel()
- static unsigned int TheLastId;
};
inline
#include "cbdata.h"
#include "MemBuf.h"
-
-unsigned int AsyncJob::TheLastId = 0;
+InstanceIdDefinitions(AsyncJob, "job");
AsyncJob::Pointer AsyncJob::Start(AsyncJob *j)
{
return job;
}
-AsyncJob::AsyncJob(const char *aTypeName): typeName(aTypeName), inCall(NULL), id(++TheLastId)
+AsyncJob::AsyncJob(const char *aTypeName): typeName(aTypeName), inCall(NULL)
{
debugs(93,5, "AsyncJob constructed, this=" << this <<
- " type=" << typeName << " [job" << id << ']');
+ " type=" << typeName << " [" << id << ']');
}
AsyncJob::~AsyncJob()
{
debugs(93,5, "AsyncJob destructed, this=" << this <<
- " type=" << typeName << " [job" << id << ']');
+ " type=" << typeName << " [" << id << ']');
}
void AsyncJob::start()
buf.Printf("Stopped, reason:");
buf.Printf("%s",stopReason);
}
- buf.Printf(" job%d]", id);
+ buf.Printf(" %s%u]", id.Prefix, id.value);
buf.terminate();
return buf.content();
#define SQUID_ASYNC_JOB_H
#include "base/AsyncCall.h"
+#include "base/InstanceId.h"
template <class Cbc>
class CbcPointer;
const char *stopReason; ///< reason for forcing done() to be true
const char *typeName; ///< kid (leaf) class name, for debugging
AsyncCall::Pointer inCall; ///< the asynchronous call being handled, if any
- const unsigned int id; ///< unique ID across all strand jobs, unless wraps
-
-private:
- static unsigned int TheLastId; ///< makes job IDs unique until it wraps
+ const InstanceId<AsyncJob> id; ///< job identifier
};
#endif /* SQUID_ASYNC_JOB_H */