Diffstat (limited to 'include/sitecing/process_manager.h') (more/less context) (show whitespace changes)
-rw-r--r-- | include/sitecing/process_manager.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/include/sitecing/process_manager.h b/include/sitecing/process_manager.h new file mode 100644 index 0000000..73415d3 --- a/dev/null +++ b/include/sitecing/process_manager.h | |||
@@ -0,0 +1,89 @@ | |||
1 | #ifndef __SITECING_PROCESS_MANAGER_H | ||
2 | #define __SITECING_PROCESS_MANAGER_H | ||
3 | |||
4 | #include <sitecing/scoreboard.h> | ||
5 | |||
6 | /** | ||
7 | * @file | ||
8 | * @brief the process manager. | ||
9 | */ | ||
10 | |||
11 | namespace sitecing { | ||
12 | |||
13 | /** | ||
14 | * The process manager. | ||
15 | */ | ||
16 | class process_manager { | ||
17 | public: | ||
18 | /** | ||
19 | * Minimum number of child processes. | ||
20 | */ | ||
21 | int min_children; | ||
22 | /** | ||
23 | * Maxinum number of child processes. | ||
24 | */ | ||
25 | int max_children; | ||
26 | /** | ||
27 | * Minimum number of spare child processes. | ||
28 | */ | ||
29 | int min_spare_children; | ||
30 | /** | ||
31 | * Maxiumum number of spare child processes. | ||
32 | */ | ||
33 | int max_spare_children; | ||
34 | /** | ||
35 | * The scoreboard. | ||
36 | */ | ||
37 | scoreboard sboard; | ||
38 | /** | ||
39 | * We're in the process of shutting down. | ||
40 | */ | ||
41 | bool finishing; | ||
42 | /** | ||
43 | * @todo TODO: wish I could rememer -- document me. | ||
44 | */ | ||
45 | bool die_humbly; | ||
46 | |||
47 | process_manager(); | ||
48 | virtual ~process_manager(); | ||
49 | |||
50 | /** | ||
51 | * The main loop. | ||
52 | */ | ||
53 | void manage(); | ||
54 | |||
55 | /** | ||
56 | * The worker function. | ||
57 | * @param the slot allocated for the process. | ||
58 | */ | ||
59 | virtual void process(int slot) = 0; | ||
60 | |||
61 | /** | ||
62 | * @todo TODO: wish I could remember -- document me. | ||
63 | */ | ||
64 | void manage_children(); | ||
65 | /** | ||
66 | * @todo TODO: wish I could remember -- document me. | ||
67 | */ | ||
68 | bool spawn_children(); | ||
69 | /** | ||
70 | * @todo TODO: wish I could remember -- document me. | ||
71 | */ | ||
72 | bool kill_children(); | ||
73 | /** | ||
74 | * @todo TODO: wish I could remember -- document me. | ||
75 | */ | ||
76 | void spawn_child(); | ||
77 | /** | ||
78 | * @todo TODO: wish I could remember -- document me. | ||
79 | */ | ||
80 | void wait_for_children(bool hang=false); | ||
81 | /** | ||
82 | * @todo TODO: wish I could remember -- document me. | ||
83 | */ | ||
84 | void collect_dead_souls(bool actively=false); | ||
85 | }; | ||
86 | |||
87 | } | ||
88 | |||
89 | #endif /* __SITECING_PROCESS_MANAGER_H */ | ||