Scarab  v2.4.9
Project 8 C++ Utility Library
signal_handler.hh
Go to the documentation of this file.
1 /*
2  * signal_handler.hh
3  *
4  * Created on: Dec 3, 2013
5  * Author: N.S. Oblath
6  */
7 
8 #ifndef SCARAB_SIGNAL_HANDLER_HH_
9 #define SCARAB_SIGNAL_HANDLER_HH_
10 
11 #include "scarab_api.hh"
12 
13 #include <memory>
14 #include <mutex>
15 #include <set>
16 
17 namespace scarab
18 {
19  class cancelable;
20 
22  {
23  public:
25  virtual ~signal_handler();
26 
28  void add_cancelable( cancelable* a_cancelable );
30  void remove_cancelable( cancelable* a_cancelable );
31 
33  void reset();
34 
36  static bool got_exit_signal();
37 
39  static void handler_cancel_threads( int _ignored );
40 
42  static void cancel_all( int a_code );
43 
44  private:
45  static void print_message();
46 
47  typedef std::set< cancelable* > cancelers;
48  typedef cancelers::const_iterator cancelers_cit_t;
49  typedef cancelers::iterator cancelers_it_t;
50 
51  static cancelers f_cancelers;
52  static std::mutex f_mutex;
53 
54  static bool f_got_exit_signal;
55 
56  static bool f_handling_sig_quit;
57  static bool f_handling_sig_int;
58 
59  };
60 
61 } /* namespace scarab */
62 #endif /* SCARAB_SIGNAL_HANDLER_HH_ */
static bool f_handling_sig_int
cancelers::iterator cancelers_it_t
cancelers::const_iterator cancelers_cit_t
#define SCARAB_API
Definition: scarab_api.hh:24
static bool f_got_exit_signal
static std::mutex f_mutex
static bool f_handling_sig_quit
static cancelers f_cancelers
std::set< cancelable *> cancelers