blob: 8e4fa36a365fd64f62fb2a83eb42e723519236ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
|