--------------------- PatchSet 6125 Date: 2007/11/13 22:51:06 Author: chtsanti Branch: async-calls Tag: (none) Log: Moving the implementation of the job() method from JobCallT to JobCall In JobCall class now a class variable used to hold the AsyncJob object and cbdataReference/cbdataReferenceDone used in JobCall constructor/destructor to be sure that the AsyncJob is remaining valid Members: src/AsyncCall.cc:1.3.22.4->1.3.22.5 src/AsyncCall.h:1.3.22.4->1.3.22.5 Index: squid3/src/AsyncCall.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/AsyncCall.cc,v retrieving revision 1.3.22.4 retrieving revision 1.3.22.5 diff -u -r1.3.22.4 -r1.3.22.5 --- squid3/src/AsyncCall.cc 13 Nov 2007 22:32:11 -0000 1.3.22.4 +++ squid3/src/AsyncCall.cc 13 Nov 2007 22:51:06 -0000 1.3.22.5 @@ -27,6 +27,18 @@ methodName << '(' << objectPtr << ')'); } +JobCall::JobCall(int debugSection, int debugLevel, const char *callName, AsyncJob *aJob): + AsyncCallBase(debugSection, debugLevel, callName) +{ + theJob = aJob; + cbdataReference(theJob->toCbdata()); +} + +JobCall::~JobCall(){ + void *cbdata=theJob->toCbdata(); + cbdataReferenceDone(cbdata); +} + bool JobCall::fire() { Index: squid3/src/AsyncCall.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/AsyncCall.h,v retrieving revision 1.3.22.4 retrieving revision 1.3.22.5 diff -u -r1.3.22.4 -r1.3.22.5 --- squid3/src/AsyncCall.h 13 Nov 2007 17:55:44 -0000 1.3.22.4 +++ squid3/src/AsyncCall.h 13 Nov 2007 22:51:06 -0000 1.3.22.5 @@ -1,6 +1,6 @@ /* - * $Id: AsyncCall.h,v 1.3.22.4 2007/11/13 17:55:44 chtsanti Exp $ + * $Id: AsyncCall.h,v 1.3.22.5 2007/11/13 22:51:06 chtsanti Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -214,15 +214,16 @@ class JobCall: public AsyncCallBase { public: - JobCall(int debugSection, int debugLevel, const char *callName): - AsyncCallBase(debugSection, debugLevel, callName){} + JobCall(int debugSection, int debugLevel, const char *callName, AsyncJob *aJob); + ~JobCall(); virtual bool fire(); virtual void handleException(const TextException &e); virtual void end(); protected: virtual void callJob() = 0; - virtual AsyncJob *job() = 0; + AsyncJob *job() {return theJob;} + AsyncJob *theJob; }; // This template combines member function pointer calling ability of MemFunT @@ -233,15 +234,9 @@ { public: JobCallT(const Dialer &aDialer,int debugSection, int debugLevel, const char *callName): - JobCall(debugSection, debugLevel, callName), theDialer(aDialer) - { - AsyncJob *job = dynamic_cast(aDialer.object()); - cbdataReference(job->toCbdata()); - } - + JobCall(debugSection, debugLevel, callName, aDialer.object()), theDialer(aDialer) {} protected: - virtual void callJob() { debugs(theDebugSection, theDebugLevel, HERE << "dialing "<< theName); theDialer(); } - virtual AsyncJob *job() {return dynamic_cast(theDialer.object());} + virtual void callJob() { debugs(theDebugSection, theDebugLevel, HERE << "dialing "<< theName); theDialer(); } private: Dialer theDialer; };