4 * DEBUG: section 54 Interprocess Communication
8 #ifndef SQUID_IPC_INQUIRER_H
9 #define SQUID_IPC_INQUIRER_H
11 #include "base/AsyncJobCalls.h"
12 #include "base/AsyncJob.h"
13 #include "ipc/forward.h"
14 #include "ipc/Request.h"
15 #include "ipc/Response.h"
16 #include "ipc/StrandCoords.h"
23 /// Coordinator's job that sends a cache manage request to each strand,
24 /// aggregating individual strand responses and dumping the result if needed
25 class Inquirer
: public AsyncJob
28 Inquirer(Request::Pointer aRequest
, const Ipc::StrandCoords
& coords
, double aTimeout
);
31 /// finds and calls the right Inquirer upon strand's response
32 static void HandleRemoteAck(const Response
& response
);
34 /* has-to-be-public AsyncJob API */
35 virtual void callException(const std::exception
& e
);
40 virtual void swanSong();
41 virtual bool doneAll() const;
42 virtual const char *status() const;
44 /// inquire the next strand
45 virtual void inquire();
46 /// perform cleanup actions on completion of job
47 virtual void cleanup();
48 /// do specific exception handling
49 virtual void handleException(const std::exception
& e
);
50 /// send response to client
51 virtual void sendResponse() = 0;
52 /// perform aggregating of responses and returns true if need to continue
53 virtual bool aggregate(Response::Pointer aResponse
) = 0;
56 typedef UnaryMemFunT
<Inquirer
, Response::Pointer
, Response::Pointer
> HandleAckDialer
;
58 void handleRemoteAck(Response::Pointer response
);
60 static AsyncCall::Pointer
DequeueRequest(unsigned int requestId
);
62 static void RequestTimedOut(void* param
);
63 void requestTimedOut();
64 void removeTimeoutEvent();
67 Request::Pointer request
; ///< cache manager request received from client
69 Ipc::StrandCoords strands
; ///< all strands we want to query, in order
70 Ipc::StrandCoords::const_iterator pos
; ///< strand we should query now
72 const double timeout
; ///< number of seconds to wait for strand response
74 /// maps request->id to Inquirer::handleRemoteAck callback
75 typedef std::map
<unsigned int, AsyncCall::Pointer
> RequestsMap
;
76 static RequestsMap TheRequestsMap
; ///< pending strand requests
78 static unsigned int LastRequestId
; ///< last requestId used
80 CBDATA_CLASS2(Inquirer
);
85 #endif /* SQUID_IPC_INQUIRER_H */