~ubuntu-branches/ubuntu/oneiric/squid3/oneiric-security

« back to all changes in this revision

Viewing changes to src/base/AsyncJob.h

  • Committer: Bazaar Package Importer
  • Author(s): Mahyuddin Susanto
  • Date: 2011-02-15 18:46:13 UTC
  • mfrom: (21.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110215184613-1u3dh5sz4i055flk
Tags: 3.1.10-1ubuntu1
* Merge from debian unstable. (LP: #719283)  Remaining changes:
  - debian/patches/18-fix-ftbfs-binutils-gold.dpatch: Add library linker into
    LIBS instead to LDFLAGS to fixing FTBFS binutils-gold.
* Drop Ubuntu configuration for ufw which landed in Debian and sync it: 
  - debian/squid3.ufw.profile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
#include "base/AsyncCall.h"
9
9
#include "TextException.h"
10
10
 
 
11
template <class Cbc>
 
12
class CbcPointer;
 
13
 
11
14
/**
12
15
 \defgroup AsyncJobAPI Async-Jobs API
13
16
 \par
29
32
 */
30
33
 
31
34
/// \ingroup AsyncJobAPI
 
35
/// Base class for all asynchronous jobs
32
36
class AsyncJob
33
37
{
34
 
 
35
 
public:
36
 
    static AsyncJob *AsyncStart(AsyncJob *job); // use this to start jobs
37
 
 
 
38
public:
 
39
    typedef CbcPointer<AsyncJob> Pointer;
 
40
 
 
41
public:
38
42
    AsyncJob(const char *aTypeName);
39
43
    virtual ~AsyncJob();
40
44
 
41
45
    virtual void *toCbdata() = 0;
42
 
    void noteStart(); // calls virtual start
 
46
 
 
47
    /// starts a freshly created job (i.e., makes the job asynchronous)
 
48
    static Pointer Start(AsyncJob *job);
43
49
 
44
50
protected:
45
51
    // XXX: temporary method to replace "delete this" in jobs-in-transition.
72
78
    static unsigned int TheLastId;
73
79
};
74
80
 
75
 
 
76
 
/**
77
 
 \ingroup AsyncJobAPI
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,
83
 
 * calling the job.
84
 
 */
85
 
class JobDialer: public CallDialer
86
 
{
87
 
public:
88
 
    JobDialer(AsyncJob *aJob);
89
 
    JobDialer(const JobDialer &d);
90
 
    virtual ~JobDialer();
91
 
 
92
 
    virtual bool canDial(AsyncCall &call);
93
 
    void dial(AsyncCall &call);
94
 
 
95
 
    AsyncJob *job;
96
 
    void *lock; // job's cbdata
97
 
 
98
 
protected:
99
 
    virtual void doDial() = 0; // actually calls the job method
100
 
 
101
 
private:
102
 
    // not implemented and should not be needed
103
 
    JobDialer &operator =(const JobDialer &);
104
 
};
105
 
 
106
 
#include "base/AsyncJobCalls.h"
107
 
 
108
 
template <class Dialer>
109
 
bool
110
 
CallJob(int debugSection, int debugLevel, const char *fileName, int fileLine,
111
 
        const char *callName, const Dialer &dialer)
112
 
{
113
 
    AsyncCall::Pointer call = asyncCall(debugSection, debugLevel, callName, dialer);
114
 
    return ScheduleCall(fileName, fileLine, call);
115
 
}
116
 
 
117
 
 
118
 
#define CallJobHere(debugSection, debugLevel, job, method) \
119
 
    CallJob((debugSection), (debugLevel), __FILE__, __LINE__, #method, \
120
 
        MemFun((job), &method))
121
 
 
122
 
#define CallJobHere1(debugSection, debugLevel, job, method, arg1) \
123
 
    CallJob((debugSection), (debugLevel), __FILE__, __LINE__, #method, \
124
 
        MemFun((job), &method, (arg1)))
125
 
 
126
 
 
127
81
#endif /* SQUID_ASYNC_JOB_H */