SignalEvent.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Scheduler_SignalEvent_
18 #define HH_SENF_Scheduler_SignalEvent_ 1
19 
20 // Custom includes
21 #include <signal.h>
22 #include <boost/function.hpp>
23 #include "FIFORunner.hh"
24 #include <boost/intrusive/set_hook.hpp>
25 
26 //#include "SignalEvent.mpp"
27 //-/////////////////////////////////////////////////////////////////////////////////////////////////
28 
29 namespace senf {
30 
31  class Scheduler;
32 
33 namespace scheduler {
34 
35  namespace detail {
36  struct SignalSetTag;
37  typedef boost::intrusive::set_base_hook< boost::intrusive::tag<SignalSetTag> > SignalSetBase;
38  struct SignalSetCompare;
39  struct FindNumericSignal;
40  class SignalDispatcher;
41  }
42 
56  {
57  public:
58  //-////////////////////////////////////////////////////////////////////////
59  // Types
60 
61  typedef boost::function<void (siginfo_t const &)> Callback;
63 
64  //-////////////////////////////////////////////////////////////////////////
66  //\{
67 
68  SignalEvent(int signal, Callback const & cb, bool initiallyEnabled=true);
70 
78  ~SignalEvent();
79 
80  //\}
81  //-////////////////////////////////////////////////////////////////////////
82 
83  void disable();
84  void enable();
85 
86  void action(Callback const & cb);
87 
88  private:
89  virtual void v_run();
90  virtual char const * v_type() const;
91  virtual std::string v_info() const;
92 
93  int signal_;
94  Callback cb_;
95  siginfo_t siginfo_;
96 
97  friend struct detail::SignalSetCompare;
98  friend struct detail::FindNumericSignal;
99  friend class detail::SignalDispatcher;
100  };
101 
102 }}
103 
104 //-/////////////////////////////////////////////////////////////////////////////////////////////////
105 #include "SignalEvent.cci"
106 //#include "SignalEvent.ct"
107 //#include "SignalEvent.cti"
108 #endif
109 
110 
111 // Local Variables:
112 // mode: c++
113 // fill-column: 100
114 // comment-column: 40
115 // c-file-style: "senf"
116 // indent-tabs-mode: nil
117 // ispell-local-dictionary: "american"
118 // compile-command: "scons -u test"
119 // End:
UNIX signal event.
Definition: SignalEvent.hh:53
FIFORunner public header.
boost::intrusive::set_base_hook< boost::intrusive::tag< SignalSetTag > > SignalSetBase
Definition: SignalEvent.hh:36
boost::function< void(siginfo_t const &)> Callback
Callback type.
Definition: SignalEvent.hh:61