]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Kids.cc
4 * DEBUG: section 54 Interprocess Communication
19 void Kids::init(size_t n
)
23 if (storage
.size() > 0)
30 // add Kid records for all n main strands
31 for (size_t i
= 1; i
<= n
; ++i
) {
32 snprintf(kid_name
, sizeof(kid_name
), "(squid-%d)", (int)i
);
33 storage
.push_back(Kid(kid_name
));
36 // if coordination is needed, add a Kid record for Coordinator
38 snprintf(kid_name
, sizeof(kid_name
), "(squid-coord-%d)", (int)(n
+ 1));
39 storage
.push_back(Kid(kid_name
));
43 /// returns kid by pid
44 Kid
* Kids::find(pid_t pid
)
49 for (size_t i
= 0; i
< storage
.size(); ++i
) {
50 if (storage
[i
].getPid() == pid
)
56 /// returns the kid by index, useful for kids iteration
57 Kid
& Kids::get(size_t i
)
63 /// whether all kids are hopeless
64 bool Kids::allHopeless() const
66 for (size_t i
= 0; i
< storage
.size(); ++i
) {
67 if (!storage
[i
].hopeless())
73 /// whether all kids called exited happy
74 bool Kids::allExitedHappy() const
76 for (size_t i
= 0; i
< storage
.size(); ++i
) {
77 if (!storage
[i
].exitedHappy())
83 /// whether all kids died from a given signal
84 bool Kids::allSignaled(int sgnl
) const
86 for (size_t i
= 0; i
< storage
.size(); ++i
) {
87 if (!storage
[i
].signaled(sgnl
))
93 /// returns the number of kids
94 size_t Kids::count() const
96 return storage
.size();