31
34
/// \ingroup AsyncJobAPI
35
/// Base class for all asynchronous jobs
36
static AsyncJob *AsyncStart(AsyncJob *job); // use this to start jobs
39
typedef CbcPointer<AsyncJob> Pointer;
38
42
AsyncJob(const char *aTypeName);
39
43
virtual ~AsyncJob();
41
45
virtual void *toCbdata() = 0;
42
void noteStart(); // calls virtual start
47
/// starts a freshly created job (i.e., makes the job asynchronous)
48
static Pointer Start(AsyncJob *job);
45
51
// XXX: temporary method to replace "delete this" in jobs-in-transition.
72
78
static unsigned int TheLastId;
78
* This is a base class for all job call dialers. It does all the job
79
* dialing logic (debugging, handling exceptions, etc.) except for calling
80
* the job method. The latter is not possible without templates and we
81
* want to keep this class simple and template-free. Thus, we add a dial()
82
* virtual method that the JobCallT template below will implement for us,
85
class JobDialer: public CallDialer
88
JobDialer(AsyncJob *aJob);
89
JobDialer(const JobDialer &d);
92
virtual bool canDial(AsyncCall &call);
93
void dial(AsyncCall &call);
96
void *lock; // job's cbdata
99
virtual void doDial() = 0; // actually calls the job method
102
// not implemented and should not be needed
103
JobDialer &operator =(const JobDialer &);
106
#include "base/AsyncJobCalls.h"
108
template <class Dialer>
110
CallJob(int debugSection, int debugLevel, const char *fileName, int fileLine,
111
const char *callName, const Dialer &dialer)
113
AsyncCall::Pointer call = asyncCall(debugSection, debugLevel, callName, dialer);
114
return ScheduleCall(fileName, fileLine, call);
118
#define CallJobHere(debugSection, debugLevel, job, method) \
119
CallJob((debugSection), (debugLevel), __FILE__, __LINE__, #method, \
120
MemFun((job), &method))
122
#define CallJobHere1(debugSection, debugLevel, job, method, arg1) \
123
CallJob((debugSection), (debugLevel), __FILE__, __LINE__, #method, \
124
MemFun((job), &method, (arg1)))
127
81
#endif /* SQUID_ASYNC_JOB_H */