--------------------- PatchSet 6206 Date: 2007/11/29 20:39:01 Author: rousskov Branch: async-calls Tag: (none) Log: Replaced job-specific scheduleJobCall() with generic ScheduleCall() and ScheduleCallHere() macros because scheduleJobCall() did not do anything job-specific. Extract debug levels from calls instead of asking for them as macro parameters. This ties debugging of scheduling with debugging of call firing, but that is probably as bad as having them separated (but requires less ink). Made AsyncCall debugging fields public. A few global functions may need them for debugging calls. Made AsyncCall debugging fields constant until somebody needs to modify them. This will also prevent call copying, which is not supported. Members: src/AsyncCall.cc:1.3.22.7->1.3.22.8 src/AsyncCall.h:1.3.22.14->1.3.22.15 Index: squid3/src/AsyncCall.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/AsyncCall.cc,v retrieving revision 1.3.22.7 retrieving revision 1.3.22.8 diff -u -r1.3.22.7 -r1.3.22.8 --- squid3/src/AsyncCall.cc 27 Nov 2007 18:36:52 -0000 1.3.22.7 +++ squid3/src/AsyncCall.cc 29 Nov 2007 20:39:01 -0000 1.3.22.8 @@ -47,27 +47,27 @@ if(!cbdataReferenceValid(theCbdata)) return false; - if (!theJob->callStart(theName)) { - debugs(theDebugSection, theDebugLevel, HERE << "job call "<< theName <<" NOT fire " << this); + if (!theJob->callStart(name)) { + debugs(debugSection, debugLevel, HERE << "job call "<< name <<" NOT fire " << this); return false; } - debugs(theDebugSection, theDebugLevel, HERE << "job call " << theName << " fire " << this); + debugs(debugSection, debugLevel, HERE << "job call " << name << " fire " << this); callJob(); - debugs(theDebugSection, theDebugLevel, HERE << theName << " fired"); + debugs(debugSection, debugLevel, HERE << name << " fired"); return true; } void JobCall::handleException(const TextException &e) { - debugs(theDebugSection, theDebugLevel, HERE << "job call exception"); + debugs(debugSection, debugLevel, HERE << "job call exception"); AsyncJob *theJob = job(); theJob->callException(e); } void JobCall::end() { - debugs(theDebugSection, theDebugLevel, HERE << "job call end"); + debugs(debugSection, debugLevel, HERE << "job call end"); AsyncJob *theJob = job(); if(!cbdataReferenceValid(theCbdata)) Index: squid3/src/AsyncCall.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/AsyncCall.h,v retrieving revision 1.3.22.14 retrieving revision 1.3.22.15 diff -u -r1.3.22.14 -r1.3.22.15 --- squid3/src/AsyncCall.h 28 Nov 2007 21:12:52 -0000 1.3.22.14 +++ squid3/src/AsyncCall.h 29 Nov 2007 20:39:01 -0000 1.3.22.15 @@ -1,6 +1,6 @@ /* - * $Id: AsyncCall.h,v 1.3.22.14 2007/11/28 21:12:52 chtsanti Exp $ + * $Id: AsyncCall.h,v 1.3.22.15 2007/11/29 20:39:01 rousskov Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -137,6 +137,7 @@ return UnaryMemFunT(object, p, arg1); } +// TODO: move up and prevent assignment and copying class AsyncCall { public: @@ -158,18 +159,18 @@ delete call; } - AsyncCall(int debugSection, int debugLevel, const char *callName): - theName(callName), theDebugSection(debugSection), theDebugLevel(debugLevel){} + AsyncCall(int aDebugSection, int aDebugLevel, const char *aName): + name(aName), debugSection(aDebugSection), debugLevel(aDebugLevel) {} virtual ~AsyncCall() {} virtual bool fire() = 0; virtual void handleException(const TextException &e) = 0; virtual void end() = 0; - const char *name() { return theName; } -protected: - const char *theName; - int theDebugSection; - int theDebugLevel; + +public: + const char *const name; + const int debugSection; + const int debugLevel; }; // Same as AsyncCall, but does not assume the object is cbdata-protected. @@ -218,7 +219,7 @@ JobCallT(const Dialer &aDialer,int debugSection, int debugLevel, const char *callName): JobCall(debugSection, debugLevel, callName, aDialer.object()), theDialer(aDialer) {} protected: - virtual void callJob() { debugs(theDebugSection, theDebugLevel, HERE << "dialing "<< theName); theDialer(); } + virtual void callJob() { debugs(debugSection, debugLevel, HERE << "dialing "<< name); theDialer(); } //private: Dialer theDialer; }; @@ -254,7 +255,19 @@ #define CallJobHere1(debugSection, debugLevel, objectPtr, callName, arg1) \ CallJob(debugSection, debugLevel, __FILE__, __LINE__, #callName, MemFun(objectPtr,&callName, arg1)) -#define scheduleJobCall(debugSection, debugLevel, call)\ - scheduleAsyncCall(debugSection, debugLevel, __FILE__, __LINE__, call, call->name(), &(AsyncCall::fireWrapper), false) +inline bool +ScheduleCall(int debugSection, int debugLevel, const char *fileName, int fileLine, AsyncCall *call){ + debugs(debugSection, debugLevel, HERE << "call=" << call); + scheduleAsyncCall(debugSection, debugLevel, fileName, fileLine, + call, call->name, + &(AsyncCall::fireWrapper), false); + + debugs(debugSection, debugLevel, HERE << "scheduled"); + return true; +} + +#define ScheduleCallHere(call) \ + ScheduleCall((call)->debugSection, (call)->debugLevel, __FILE__, __LINE__, \ + (call)) #endif /* SQUID_ASYNCCALL_H */