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