]> git.ipfire.org Git - thirdparty/squid.git/blob - src/helper/ChildConfig.h
SourceLayout: shuffle HelperChildConfig into libhelper.la
[thirdparty/squid.git] / src / helper / ChildConfig.h
1 /*
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef _SQUID_SRC_HELPER_CHILDCONFIG_H
10 #define _SQUID_SRC_HELPER_CHILDCONFIG_H
11
12 namespace Helper
13 {
14
15 /**
16 * Contains statistics of a particular type of child helper.
17 *
18 * Some derived from a helper children configuration option,
19 * some from runtime stats on the currently active children.
20 */
21 class ChildConfig
22 {
23 public:
24 explicit ChildConfig(const unsigned int m = 0);
25
26 /**
27 * When new helpers are needed call this to find out how many more
28 * we are allowed to start.
29 * \retval 0 No more helpers may be started right now.
30 * \retval N < 0 Error. No more helpers may be started.
31 * \retval N N more helpers may be started immediately.
32 */
33 int needNew() const;
34 void parseConfig();
35
36 /**
37 * Update an existing set of details with new start/max/idle/concurrent limits.
38 * This is for parsing new child settings into an object incrementally then updating
39 * the running set without loosing any of the active state or causing races.
40 */
41 ChildConfig &updateLimits(const ChildConfig &rhs);
42
43 /* values from squid.conf */
44 public:
45
46 /** maximum child process limits. How many of this helper the system can cope with */
47 unsigned int n_max;
48
49 /**
50 * Number of children to kick off at startup.
51 * set via the startup=N option.
52 *
53 * By default if undefined 1 will be started immediately for use.
54 * The minimum/idle amount will be scheduled for starting as soon as possible after startup is completed.
55 */
56 unsigned int n_startup;
57
58 /**
59 * Number of helper children to keep available as a buffer against sudden bursts of requests.
60 * set via the idle=N option. May be zero.
61 *
62 * The default value for backward compatibility the default for this is the same as maximum children.
63 * For now the actual number of idle children is only reduced by a reconfigure operation. This may change.
64 */
65 unsigned int n_idle;
66
67 /**
68 * How many concurrent requests each child helper may be capable of handling.
69 * Default: 0 - no concurrency possible.
70 */
71 unsigned int concurrency;
72
73 /* derived from active operations */
74
75 /**
76 * Total helper children objects currently existing.
77 * Produced as a side effect of starting children or their stopping.
78 */
79 unsigned int n_running;
80
81 /**
82 * Count of helper children active (not shutting down).
83 * This includes both idle and in-use children.
84 */
85 unsigned int n_active;
86 };
87
88 } // namespace Helper
89
90 /* Legacy parser interface */
91 #define parse_HelperChildConfig(c) (c)->parseConfig()
92 #define dump_HelperChildConfig(e,n,c) storeAppendPrintf((e), "\n%s %d startup=%d idle=%d concurrency=%d\n", (n), (c).n_max, (c).n_startup, (c).n_idle, (c).concurrency)
93 #define free_HelperChildConfig(dummy) // NO.
94
95 #endif /* _SQUID_SRC_HELPER_CHILDCONFIG_H */