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"
22 /// Coordinator's job that sends a cache manage request to each strand,
23 /// aggregating individual strand responses and dumping the result if needed
24 class Inquirer
: public AsyncJob
27 Inquirer(Request::Pointer aRequest
, const Ipc::StrandCoords
& coords
, double aTimeout
);
30 /// finds and calls the right Inquirer upon strand's response
31 static void HandleRemoteAck(const Response
& response
);
33 /* has-to-be-public AsyncJob API */
34 virtual void callException(const std::exception
& e
);
39 virtual void swanSong();
40 virtual bool doneAll() const;
41 virtual const char *status() const;
43 /// inquire the next strand
44 virtual void inquire();
45 /// perform cleanup actions on completion of job
46 virtual void cleanup();
47 /// do specific exception handling
48 virtual void handleException(const std::exception
& e
);
49 /// send response to client
50 virtual void sendResponse() = 0;
51 /// perform aggregating of responses and returns true if need to continue
52 virtual bool aggregate(Response::Pointer aResponse
) = 0;
55 typedef UnaryMemFunT
<Inquirer
, Response::Pointer
, Response::Pointer
> HandleAckDialer
;
57 void handleRemoteAck(Response::Pointer response
);
59 static AsyncCall::Pointer
DequeueRequest(unsigned int requestId
);
61 static void RequestTimedOut(void* param
);
62 void requestTimedOut();
63 void removeTimeoutEvent();
66 Request::Pointer request
; ///< cache manager request received from client
68 Ipc::StrandCoords strands
; ///< all strands we want to query, in order
69 Ipc::StrandCoords::const_iterator pos
; ///< strand we should query now
71 const double timeout
; ///< number of seconds to wait for strand response
73 /// maps request->id to Inquirer::handleRemoteAck callback
74 typedef std::map
<unsigned int, AsyncCall::Pointer
> RequestsMap
;
75 static RequestsMap TheRequestsMap
; ///< pending strand requests
77 static unsigned int LastRequestId
; ///< last requestId used
79 CBDATA_CLASS2(Inquirer
);
84 #endif /* SQUID_IPC_INQUIRER_H */