Forwarder.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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 "cbdata.h"
16 #include "ipc/Request.h"
17 #include "mgr/ActionParams.h"
18 
19 #include <map>
20 
21 namespace Ipc
22 {
23 
28 class Forwarder: public AsyncJob
29 {
31 
32 public:
33  Forwarder(Request::Pointer aRequest, double aTimeout);
34  virtual ~Forwarder();
35 
37  static void HandleRemoteAck(unsigned int requestId);
38 
39  /* has-to-be-public AsyncJob API */
40  virtual void callException(const std::exception& e);
41 
42 protected:
43  /* AsyncJob API */
44  virtual void start();
45  virtual void swanSong();
46  virtual bool doneAll() const;
47 
48  virtual void handleError();
49  virtual void handleTimeout();
50  virtual void handleException(const std::exception& e);
51 
52 private:
53  static void RequestTimedOut(void* param);
54  void requestTimedOut();
55  void removeTimeoutEvent();
56 
57  void handleRemoteAck();
58 
59  static AsyncCall::Pointer DequeueRequest(unsigned int requestId);
60 
61 protected:
63  const double timeout;
64 
66  typedef std::map<unsigned int, AsyncCall::Pointer> RequestsMap;
68 
69  static unsigned int LastRequestId;
70 };
71 
72 } // namespace Ipc
73 
74 #endif /* SQUID_IPC_FORWARDER_H */
75 
static unsigned int LastRequestId
last requestId used
Definition: Forwarder.h:69
virtual void handleException(const std::exception &e)
terminate with an error
Definition: Forwarder.cc:129
CBDATA_CLASS(Forwarder)
Request::Pointer request
Definition: Forwarder.h:62
void handleRemoteAck()
called when Coordinator starts processing the request
Definition: Forwarder.cc:86
Forwarder(Request::Pointer aRequest, double aTimeout)
Definition: Forwarder.cc:26
std::map< unsigned int, AsyncCall::Pointer > RequestsMap
maps request->id to Forwarder::handleRemoteAck callback
Definition: Forwarder.h:66
const double timeout
response wait timeout in seconds
Definition: Forwarder.h:63
virtual void handleTimeout()
Definition: Forwarder.cc:122
virtual void handleError()
Definition: Forwarder.cc:116
virtual void swanSong()
Definition: Forwarder.cc:67
static void HandleRemoteAck(unsigned int requestId)
finds and calls the right Forwarder upon Coordinator's response
Definition: Forwarder.cc:171
virtual void start()
called by AsyncStart; do not call directly
Definition: Forwarder.cc:40
void removeTimeoutEvent()
called when we are no longer waiting for Coordinator to respond
Definition: Forwarder.cc:164
static RequestsMap TheRequestsMap
pending Coordinator requests
Definition: Forwarder.h:67
static AsyncCall::Pointer DequeueRequest(unsigned int requestId)
returns and forgets the right Forwarder callback for the request
Definition: Forwarder.cc:148
virtual bool doneAll() const
whether positive goal has been reached
Definition: Forwarder.cc:78
void requestTimedOut()
called when Coordinator fails to start processing the request [in time]
Definition: Forwarder.cc:109
virtual void callException(const std::exception &e)
called when the job throws during an async call
Definition: Forwarder.cc:136
static void RequestTimedOut(void *param)
Ipc::Forwarder::requestTimedOut wrapper.
Definition: Forwarder.cc:98
virtual ~Forwarder()
Definition: Forwarder.cc:32

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors