Forwarder.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 /* 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 cleanup();
49  virtual void handleError();
50  virtual void handleTimeout();
51  virtual void handleException(const std::exception& e);
52 
53 private:
54  static void RequestTimedOut(void* param);
55  void requestTimedOut();
56  void removeTimeoutEvent();
57 
58  void handleRemoteAck();
59 
60  static AsyncCall::Pointer DequeueRequest(unsigned int requestId);
61 
62 protected:
64  const double timeout;
65 
67  typedef std::map<unsigned int, AsyncCall::Pointer> RequestsMap;
69 
70  static unsigned int LastRequestId;
71 };
72 
73 } // namespace Ipc
74 
75 #endif /* SQUID_IPC_FORWARDER_H */
76 
static unsigned int LastRequestId
last requestId used
Definition: Forwarder.h:70
virtual void handleException(const std::exception &e)
terminate with an error
Definition: Forwarder.cc:135
CBDATA_CLASS(Forwarder)
Request::Pointer request
Definition: Forwarder.h:63
void handleRemoteAck()
called when Coordinator starts processing the request
Definition: Forwarder.cc:94
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:67
const double timeout
response wait timeout in seconds
Definition: Forwarder.h:64
virtual void handleTimeout()
Definition: Forwarder.cc:128
virtual void handleError()
Definition: Forwarder.cc:122
virtual void swanSong()
Definition: Forwarder.cc:74
static void HandleRemoteAck(unsigned int requestId)
finds and calls the right Forwarder upon Coordinator's response
Definition: Forwarder.cc:177
virtual void start()
called by AsyncStart; do not call directly
Definition: Forwarder.cc:47
void removeTimeoutEvent()
called when we are no longer waiting for Coordinator to respond
Definition: Forwarder.cc:170
virtual void cleanup()
perform cleanup actions
Definition: Forwarder.cc:42
static RequestsMap TheRequestsMap
pending Coordinator requests
Definition: Forwarder.h:68
static AsyncCall::Pointer DequeueRequest(unsigned int requestId)
returns and forgets the right Forwarder callback for the request
Definition: Forwarder.cc:154
virtual bool doneAll() const
whether positive goal has been reached
Definition: Forwarder.cc:86
void requestTimedOut()
called when Coordinator fails to start processing the request [in time]
Definition: Forwarder.cc:115
virtual void callException(const std::exception &e)
called when the job throws during an async call
Definition: Forwarder.cc:142
static void RequestTimedOut(void *param)
Ipc::Forwarder::requestTimedOut wrapper.
Definition: Forwarder.cc:104
virtual ~Forwarder()
Definition: Forwarder.cc:33

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors