Forwarder.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_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
22namespace Ipc
23{
24
29class Forwarder: public AsyncJob
30{
32
33public:
34 Forwarder(Request::Pointer aRequest, double aTimeout);
35 ~Forwarder() override;
36
38 static void HandleRemoteAck(RequestId);
39
40 /* has-to-be-public AsyncJob API */
41 void callException(const std::exception& e) override;
42
44
45protected:
46 /* AsyncJob API */
47 void start() override;
48 void swanSong() override;
49 bool doneAll() const override;
50
51 virtual void handleError();
52 virtual void handleTimeout();
53 virtual void handleException(const std::exception& e);
54
55private:
56 static void RequestTimedOut(void* param);
57 void requestTimedOut();
58 void removeTimeoutEvent();
59
60 void handleRemoteAck();
61
63
64protected:
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
void removeTimeoutEvent()
called when we are no longer waiting for Coordinator to respond
Definition: Forwarder.cc:167
void start() override
called by AsyncStart; do not call directly
Definition: Forwarder.cc:40
std::map< RequestId::Index, AsyncCall::Pointer > RequestsMap
maps request->id to Forwarder::handleRemoteAck callback
Definition: Forwarder.h:69
Forwarder(Request::Pointer aRequest, double aTimeout)
Definition: Forwarder.cc:25
bool doneAll() const override
whether positive goal has been reached
Definition: Forwarder.cc:78
static AsyncCall::Pointer DequeueRequest(RequestId::Index)
returns and forgets the right Forwarder callback for the request
Definition: Forwarder.cc:151
void handleRemoteAck()
called when Coordinator starts processing the request
Definition: Forwarder.cc:86
static RequestId::Index LastRequestId
last requestId used
Definition: Forwarder.h:72
virtual void handleTimeout()
Definition: Forwarder.cc:125
void requestTimedOut()
called when Coordinator fails to start processing the request [in time]
Definition: Forwarder.cc:112
void callException(const std::exception &e) override
called when the job throws during an async call
Definition: Forwarder.cc:139
static RequestsMap TheRequestsMap
pending Coordinator requests
Definition: Forwarder.h:70
virtual void handleError()
Definition: Forwarder.cc:119
virtual void handleException(const std::exception &e)
terminate with an error
Definition: Forwarder.cc:132
void swanSong() override
Definition: Forwarder.cc:67
static void HandleRemoteAck(RequestId)
finds and calls the right Forwarder upon Coordinator's response
Definition: Forwarder.cc:174
~Forwarder() override
Definition: Forwarder.cc:32
const double timeout
response wait timeout in seconds
Definition: Forwarder.h:66
static void RequestTimedOut(void *param)
Ipc::Forwarder::requestTimedOut wrapper.
Definition: Forwarder.cc:98
Request::Pointer request
Definition: Forwarder.h:65
CodeContextPointer codeContext
Definition: Forwarder.h:43
unsigned int Index
Definition: RequestId.h:27
Definition: IpcIoFile.h:24

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors