AsyncJob.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_ASYNC_JOB_H
10 #define SQUID_ASYNC_JOB_H
11 
12 #include "base/AsyncCall.h"
13 #include "base/InstanceId.h"
14 #include "cbdata.h"
15 
16 template <class Cbc>
17 class CbcPointer;
18 
27 // See AsyncJobs.dox for details.
28 
31 class AsyncJob: public CbdataParent
32 {
33 public:
35 
36 public:
37  AsyncJob(const char *aTypeName);
38  virtual ~AsyncJob();
39 
41  static Pointer Start(AsyncJob *job);
42 
43 protected:
44  // XXX: temporary method to replace "delete this" in jobs-in-transition.
45  // Will be replaced with calls to mustStop() when transition is complete.
46  void deleteThis(const char *aReason);
47 
48  // force done() for a reason but continue with the current method
49  void mustStop(const char *aReason);
50 
51  bool done() const;
52 
53  virtual void start();
54  virtual bool doneAll() const;
55  virtual void swanSong() {};
56  virtual const char *status() const;
57 
58 public:
59  bool canBeCalled(AsyncCall &call) const;
60  void callStart(AsyncCall &call);
61  virtual void callEnd();
63  virtual void callException(const std::exception &e);
65 
66 protected:
67  const char *stopReason;
68  const char *typeName;
71 };
72 
73 #endif /* SQUID_ASYNC_JOB_H */
74 
bool done() const
the job is destroyed in callEnd() when done()
Definition: AsyncJob.cc:90
bool canBeCalled(AsyncCall &call) const
whether we can be called
Definition: AsyncJob.cc:101
virtual bool doneAll() const
whether positive goal has been reached
Definition: AsyncJob.cc:96
void mustStop(const char *aReason)
Definition: AsyncJob.cc:69
AsyncCall::Pointer inCall
the asynchronous call being handled, if any
Definition: AsyncJob.h:69
AsyncJob(const char *aTypeName)
Definition: AsyncJob.cc:30
const InstanceId< AsyncJob > id
job identifier
Definition: AsyncJob.h:70
virtual void callException(const std::exception &e)
called when the job throws during an async call
Definition: AsyncJob.cc:127
virtual const char * status() const
internal cleanup; do not call directly
Definition: AsyncJob.cc:159
static Pointer Start(AsyncJob *job)
starts a freshly created job (i.e., makes the job asynchronous)
Definition: AsyncJob.cc:23
virtual void swanSong()
Definition: AsyncJob.h:55
void deleteThis(const char *aReason)
Definition: AsyncJob.cc:49
CbcPointer< AsyncJob > Pointer
Definition: AsyncJob.h:34
const char * stopReason
reason for forcing done() to be true
Definition: AsyncJob.h:67
virtual ~AsyncJob()
Definition: AsyncJob.cc:37
virtual void callEnd()
called right after the called job method
Definition: AsyncJob.cc:136
virtual void start()
called by AsyncStart; do not call directly
Definition: AsyncJob.cc:43
const char * typeName
kid (leaf) class name, for debugging
Definition: AsyncJob.h:68
void callStart(AsyncCall &call)
Definition: AsyncJob.cc:114

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors