Inquirer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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_SRC_IPC_INQUIRER_H
12 #define SQUID_SRC_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 
22 namespace Ipc
23 {
24 
27 class Inquirer: public AsyncJob
28 {
30 
31 public:
32  Inquirer(Request::Pointer aRequest, const Ipc::StrandCoords& coords, double aTimeout);
33  ~Inquirer() override;
34 
36  static void HandleRemoteAck(const Response& response);
37 
38  /* has-to-be-public AsyncJob API */
39  void callException(const std::exception& e) override;
40 
42 
43 protected:
44  /* AsyncJob API */
45  void start() override;
46  void swanSong() override;
47  bool doneAll() const override;
48  const char *status() const override;
49 
51  virtual void inquire();
53  virtual void cleanup();
55  virtual void handleException(const std::exception& e);
57  virtual void sendResponse() = 0;
59  virtual bool aggregate(Response::Pointer aResponse) = 0;
60 
61 private:
62  void handleRemoteAck(Response::Pointer response);
63 
64  static void RequestTimedOut(void* param);
65  void requestTimedOut();
66  void removeTimeoutEvent();
67 
68 protected:
70 
72  Ipc::StrandCoords::const_iterator pos;
73 
74  const double timeout;
75 
77 };
78 
79 } // namespace Ipc
80 
81 #endif /* SQUID_SRC_IPC_INQUIRER_H */
82 
CodeContextPointer codeContext
Definition: Inquirer.h:41
Request::Pointer request
cache manager request received from client
Definition: Inquirer.h:69
void swanSong() override
Definition: Inquirer.cc:133
bool doneAll() const override
whether positive goal has been reached
Definition: Inquirer.cc:146
virtual void sendResponse()=0
send response to client
Ipc::StrandCoords::const_iterator pos
strand we should query now
Definition: Inquirer.h:72
A response to Ipc::Request.
Definition: Response.h:23
void start() override
called by AsyncStart; do not call directly
Definition: Inquirer.cc:89
const char * status() const override
internal cleanup; do not call directly
Definition: Inquirer.cc:220
Inquirer(Request::Pointer aRequest, const Ipc::StrandCoords &coords, double aTimeout)
Definition: Inquirer.cc:65
void requestTimedOut()
called when the strand failed to respond (or finish responding) in time
Definition: Inquirer.cc:207
static void RequestTimedOut(void *param)
Ipc::Inquirer::requestTimedOut wrapper.
Definition: Inquirer.cc:194
virtual void cleanup()
perform cleanup actions on completion of job
Definition: Inquirer.cc:84
const double timeout
number of seconds to wait for strand response
Definition: Inquirer.h:74
void callException(const std::exception &e) override
called when the job throws during an async call
Definition: Inquirer.cc:159
virtual void handleException(const std::exception &e)
do specific exception handling
Definition: Inquirer.cc:152
virtual void inquire()
inquire the next strand
Definition: Inquirer.cc:95
virtual bool aggregate(Response::Pointer aResponse)=0
perform aggregating of responses and returns true if need to continue
void removeTimeoutEvent()
called when we are no longer waiting for the strand to respond
Definition: Inquirer.cc:186
unsigned int Index
Definition: RequestId.h:27
static void HandleRemoteAck(const Response &response)
finds and calls the right Inquirer upon strand's response
Definition: Inquirer.cc:171
std::vector< StrandCoord > StrandCoords
a collection of strand coordinates; the order, if any, is owner-dependent
Definition: StrandCoords.h:19
static RequestId::Index LastRequestId
last requestId used
Definition: Inquirer.h:76
~Inquirer() override
Definition: Inquirer.cc:77
void handleRemoteAck(Response::Pointer response)
called when a strand is done writing its output
Definition: Inquirer.cc:118
Ipc::StrandCoords strands
all strands we want to query, in order
Definition: Inquirer.h:71
Definition: IpcIoFile.h:23

 

Introduction

Documentation

Support

Miscellaneous