]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Coordinator.h
Switched from sendto/recvfrom to sendmsg/recvmsg for UDS I/O. Replaced
[thirdparty/squid.git] / src / ipc / Coordinator.h
1 /*
2 * $Id$
3 *
4 * DEBUG: section 54 Interprocess Communication
5 *
6 */
7
8 #ifndef SQUID_IPC_COORDINATOR_H
9 #define SQUID_IPC_COORDINATOR_H
10
11
12 #include "Array.h"
13 #include "ipc/Port.h"
14 #include "ipc/Messages.h"
15
16 namespace Ipc
17 {
18
19 /// Coordinates shared activities of Strands (Squid processes or threads)
20 class Coordinator: public Port
21 {
22 public:
23 static Coordinator* Instance();
24
25 public:
26 Coordinator();
27
28 void broadcastSignal(int sig) const; ///< send sig to registered strands
29
30 protected:
31 virtual void start(); // Port (AsyncJob) API
32 virtual void receive(const TypedMsgHdr& message); // Port API
33
34 StrandCoord* findStrand(int kidId); ///< registered strand or NULL
35 void registerStrand(const StrandCoord &); ///< adds or updates existing
36 void handleRegistrationRequest(const StrandCoord &); ///< register,ACK
37
38 private:
39 typedef Vector<StrandCoord> Strands; ///< unsorted strands
40 Strands strands; ///< registered processes and threads
41 static Coordinator* TheInstance; ///< the only class instance in existence
42
43 CBDATA_CLASS2(Coordinator);
44
45 private:
46 Coordinator(const Coordinator&); // not implemented
47 Coordinator& operator =(const Coordinator&); // not implemented
48 };
49
50
51 } // namespace Ipc
52
53 #endif /* SQUID_IPC_COORDINATOR_H */