From 98cef5e9a772602d42acfcf233838c760424db9a Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Thu, 13 Feb 2025 18:00:17 +1100 Subject: initial commit --- comp3331/server/src/shared/shared.hh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 comp3331/server/src/shared/shared.hh (limited to 'comp3331/server/src/shared/shared.hh') 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 +#include +#include +#include + +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; + func_t func; + +public: + scoped_function(const func_t& f) : func(f) {} + ~scoped_function() { this->func(); } +}; +} // namespace shared + +#endif -- cgit v1.2.3