aboutsummaryrefslogtreecommitdiff
path: root/comp3331/server/src/shared/shared.hh
diff options
context:
space:
mode:
authorNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-13 18:00:17 +1100
committerNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-13 18:00:17 +1100
commit98cef5e9a772602d42acfcf233838c760424db9a (patch)
tree5277fa1d7cc0a69a0f166fcbf10fd320f345f049 /comp3331/server/src/shared/shared.hh
initial commit
Diffstat (limited to 'comp3331/server/src/shared/shared.hh')
-rw-r--r--comp3331/server/src/shared/shared.hh28
1 files changed, 28 insertions, 0 deletions
diff --git a/comp3331/server/src/shared/shared.hh b/comp3331/server/src/shared/shared.hh
new file mode 100644
index 0000000..8e4fa36
--- /dev/null
+++ b/comp3331/server/src/shared/shared.hh
@@ -0,0 +1,28 @@
+#ifndef SHARED_SHARED_HH_
+#define SHARED_SHARED_HH_
+
+#include <functional>
+#include <iostream>
+#include <signal.h>
+#include <stdexcept>
+
+namespace shared {
+extern bool should_exit;
+
+void set_exit_handler();
+
+class should_exit_exception : public std::exception {};
+
+// This won't exist until c++24 lol
+class scoped_function {
+private:
+ using func_t = std::function<void()>;
+ func_t func;
+
+public:
+ scoped_function(const func_t& f) : func(f) {}
+ ~scoped_function() { this->func(); }
+};
+} // namespace shared
+
+#endif