Forwarder.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_FORWARDER_H
12 #define SQUID_IPC_FORWARDER_H
13 
14 #include "base/AsyncJob.h"
15 #include "base/forward.h"
16 #include "cbdata.h"
17 #include "ipc/Request.h"
18 #include "mgr/ActionParams.h"
19 
20 #include <map>
21 
22 namespace Ipc
23 {
24 
29 class Forwarder: public AsyncJob
30 {
32 
33 public:
34  Forwarder(Request::Pointer aRequest, double aTimeout);
35  virtual ~Forwarder();
36 
38  static void HandleRemoteAck(RequestId);
39 
40  /* has-to-be-public AsyncJob API */
41  virtual void callException(const std::exception& e);
42 
44 
45 protected:
46  /* AsyncJob API */
47  virtual void start();
48  virtual void swanSong();
49  virtual bool doneAll() const;
50 
51  virtual void handleError();
52  virtual void handleTimeout();
53  virtual void handleException(const std::exception& e);
54 
55 private:
56  static void RequestTimedOut(void* param);
57  void requestTimedOut();
58  void removeTimeoutEvent();
59 
60  void handleRemoteAck();
61 
63 
64 protected:
66  const double timeout;
67 
69  typedef std::map<RequestId::Index, AsyncCall::Pointer> RequestsMap;
71 
73 };
74 
75 } // namespace Ipc
76 
77 #endif /* SQUID_IPC_FORWARDER_H */
78 
static RequestsMap TheRequestsMap
pending Coordinator requests
Definition: Forwarder.h:70
static RequestId::Index LastRequestId
last requestId used
Definition: Forwarder.h:72
static void RequestTimedOut(void *param)
Ipc::Forwarder::requestTimedOut wrapper.
Definition: Forwarder.cc:100
static void HandleRemoteAck(RequestId)
finds and calls the right Forwarder upon Coordinator's response
Definition: Forwarder.cc:176
void handleRemoteAck()
called when Coordinator starts processing the request
Definition: Forwarder.cc:88
virtual void handleException(const std::exception &e)
terminate with an error
Definition: Forwarder.cc:134
const double timeout
response wait timeout in seconds
Definition: Forwarder.h:66
virtual void start()
called by AsyncStart; do not call directly
Definition: Forwarder.cc:42
virtual void swanSong()
Definition: Forwarder.cc:69
std::map< RequestId::Index, AsyncCall::Pointer > RequestsMap
maps request->id to Forwarder::handleRemoteAck callback
Definition: Forwarder.h:69
Request::Pointer request
Definition: Forwarder.h:65
void requestTimedOut()
called when Coordinator fails to start processing the request [in time]
Definition: Forwarder.cc:114
virtual void handleTimeout()
Definition: Forwarder.cc:127
virtual ~Forwarder()
Definition: Forwarder.cc:34
virtual bool doneAll() const
whether positive goal has been reached
Definition: Forwarder.cc:80
CBDATA_CLASS(Forwarder)
static AsyncCall::Pointer DequeueRequest(RequestId::Index)
returns and forgets the right Forwarder callback for the request
Definition: Forwarder.cc:153
virtual void handleError()
Definition: Forwarder.cc:121
CodeContextPointer codeContext
Definition: Forwarder.h:43
virtual void callException(const std::exception &e)
called when the job throws during an async call
Definition: Forwarder.cc:141
unsigned int Index
Definition: RequestId.h:27
Forwarder(Request::Pointer aRequest, double aTimeout)
Definition: Forwarder.cc:27
void removeTimeoutEvent()
called when we are no longer waiting for Coordinator to respond
Definition: Forwarder.cc:169
Definition: IpcIoFile.h:24

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors