summaryrefslogtreecommitdiffabout
path: root/include/sitecing/process_manager.h
Side-by-side diff
Diffstat (limited to 'include/sitecing/process_manager.h') (more/less context) (ignore whitespace changes)
-rw-r--r--include/sitecing/process_manager.h89
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 @@
+#ifndef __SITECING_PROCESS_MANAGER_H
+#define __SITECING_PROCESS_MANAGER_H
+
+#include <sitecing/scoreboard.h>
+
+/**
+ * @file
+ * @brief the process manager.
+ */
+
+namespace sitecing {
+
+ /**
+ * The process manager.
+ */
+ class process_manager {
+ public:
+ /**
+ * Minimum number of child processes.
+ */
+ int min_children;
+ /**
+ * Maxinum number of child processes.
+ */
+ int max_children;
+ /**
+ * Minimum number of spare child processes.
+ */
+ int min_spare_children;
+ /**
+ * Maxiumum number of spare child processes.
+ */
+ int max_spare_children;
+ /**
+ * The scoreboard.
+ */
+ scoreboard sboard;
+ /**
+ * We're in the process of shutting down.
+ */
+ bool finishing;
+ /**
+ * @todo TODO: wish I could rememer -- document me.
+ */
+ bool die_humbly;
+
+ process_manager();
+ virtual ~process_manager();
+
+ /**
+ * The main loop.
+ */
+ void manage();
+
+ /**
+ * The worker function.
+ * @param the slot allocated for the process.
+ */
+ virtual void process(int slot) = 0;
+
+ /**
+ * @todo TODO: wish I could remember -- document me.
+ */
+ void manage_children();
+ /**
+ * @todo TODO: wish I could remember -- document me.
+ */
+ bool spawn_children();
+ /**
+ * @todo TODO: wish I could remember -- document me.
+ */
+ bool kill_children();
+ /**
+ * @todo TODO: wish I could remember -- document me.
+ */
+ void spawn_child();
+ /**
+ * @todo TODO: wish I could remember -- document me.
+ */
+ void wait_for_children(bool hang=false);
+ /**
+ * @todo TODO: wish I could remember -- document me.
+ */
+ void collect_dead_souls(bool actively=false);
+ };
+
+}
+
+#endif /* __SITECING_PROCESS_MANAGER_H */