Inquirer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2022 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 /* DEBUG: section 54 Interprocess Communication */
10 
11 #ifndef SQUID_IPC_INQUIRER_H
12 #define SQUID_IPC_INQUIRER_H
13 
14 #include "base/AsyncJob.h"
15 #include "base/AsyncJobCalls.h"
16 #include "base/forward.h"
17 #include "ipc/forward.h"
18 #include "ipc/Request.h"
19 #include "ipc/Response.h"
20 #include "ipc/StrandCoords.h"
21 #include <map>
22 
23 namespace Ipc
24 {
25 
28 class Inquirer: public AsyncJob
29 {
31 
32 public:
33  Inquirer(Request::Pointer aRequest, const Ipc::StrandCoords& coords, double aTimeout);
34  virtual ~Inquirer();
35 
37  static void HandleRemoteAck(const Response& response);
38 
39  /* has-to-be-public AsyncJob API */
40  virtual void callException(const std::exception& e);
41 
43 
44 protected:
45  /* AsyncJob API */
46  virtual void start();
47  virtual void swanSong();
48  virtual bool doneAll() const;
49  virtual const char *status() const;
50 
52  virtual void inquire();
54  virtual void cleanup();
56  virtual void handleException(const std::exception& e);
58  virtual void sendResponse() = 0;
60  virtual bool aggregate(Response::Pointer aResponse) = 0;
61 
62 private:
64 
65  void handleRemoteAck(Response::Pointer response);
66 
68 
69  static void RequestTimedOut(void* param);
70  void requestTimedOut();
71  void removeTimeoutEvent();
72 
73 protected:
75 
77  Ipc::StrandCoords::const_iterator pos;
78 
79  const double timeout;
80 
82  typedef std::map<RequestId::Index, AsyncCall::Pointer> RequestsMap;
84 
86 };
87 
88 } // namespace Ipc
89 
90 #endif /* SQUID_IPC_INQUIRER_H */
91 
virtual bool doneAll() const
whether positive goal has been reached
Definition: Inquirer.cc:116
static RequestId::Index LastRequestId
last requestId used
Definition: Inquirer.h:85
static void RequestTimedOut(void *param)
Ipc::Inquirer::requestTimedOut wrapper.
Definition: Inquirer.cc:179
virtual void swanSong()
Definition: Inquirer.cc:103
virtual void handleException(const std::exception &e)
do specific exception handling
Definition: Inquirer.cc:122
static RequestsMap TheRequestsMap
pending strand requests
Definition: Inquirer.h:83
CodeContextPointer codeContext
Definition: Inquirer.h:42
virtual void callException(const std::exception &e)
called when the job throws during an async call
Definition: Inquirer.cc:129
static AsyncCall::Pointer DequeueRequest(RequestId::Index)
returns and forgets the right Inquirer callback for strand request
Definition: Inquirer.cc:142
virtual void cleanup()
perform cleanup actions on completion of job
Definition: Inquirer.cc:52
const double timeout
number of seconds to wait for strand response
Definition: Inquirer.h:79
virtual void start()
called by AsyncStart; do not call directly
Definition: Inquirer.cc:57
UnaryMemFunT< Inquirer, Response::Pointer, Response::Pointer > HandleAckDialer
Definition: Inquirer.h:63
Ipc::StrandCoords::const_iterator pos
strand we should query now
Definition: Inquirer.h:77
virtual void inquire()
inquire the next strand
Definition: Inquirer.cc:63
std::map< RequestId::Index, AsyncCall::Pointer > RequestsMap
maps request->id to Inquirer::handleRemoteAck callback
Definition: Inquirer.h:82
virtual bool aggregate(Response::Pointer aResponse)=0
perform aggregating of responses and returns true if need to continue
Inquirer(Request::Pointer aRequest, const Ipc::StrandCoords &coords, double aTimeout)
Definition: Inquirer.cc:33
virtual void sendResponse()=0
send response to client
Request::Pointer request
cache manager request received from client
Definition: Inquirer.h:74
virtual const char * status() const
internal cleanup; do not call directly
Definition: Inquirer.cc:205
CBDATA_CLASS(Inquirer)
static void HandleRemoteAck(const Response &response)
finds and calls the right Inquirer upon strand's response
Definition: Inquirer.cc:157
Ipc::StrandCoords strands
all strands we want to query, in order
Definition: Inquirer.h:76
void removeTimeoutEvent()
called when we are no longer waiting for the strand to respond
Definition: Inquirer.cc:171
virtual ~Inquirer()
Definition: Inquirer.cc:45
void requestTimedOut()
called when the strand failed to respond (or finish responding) in time
Definition: Inquirer.cc:192
void handleRemoteAck(Response::Pointer response)
called when a strand is done writing its output
Definition: Inquirer.cc:88
unsigned int Index
Definition: RequestId.h:27
A response to Ipc::Request.
Definition: Response.h:24
Definition: IpcIoFile.h:24
std::vector< StrandCoord > StrandCoords
a collection of strand coordinates; the order, if any, is owner-dependent
Definition: StrandCoords.h:19

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors