IdleEvent.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_IdleEvent_
18 #define HH_SENF_Scheduler_IdleEvent_ 1
19 
20 // Custom includes
21 #include <boost/function.hpp>
22 #include <boost/intrusive/list_hook.hpp>
23 #include "FIFORunner.hh"
24 
25 //#include "IdleEvent.mpp"
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 
28 namespace senf {
29 namespace scheduler {
30 
31 namespace detail {
32  struct IdleEventListTag;
33  typedef boost::intrusive::list_base_hook< boost::intrusive::tag<IdleEventListTag> > IdleEventListBase;
34  class IdleEventDispatcher;
35 }
36 
37  class IdleEvent
40  {
41  public:
42  //-////////////////////////////////////////////////////////////////////////
43  // Types
44 
45  typedef boost::function<void ()> Callback;
46 
47  //-////////////////////////////////////////////////////////////////////////
49  //\{
50 
51  IdleEvent(std::string const & name, Callback const & cb,
52  bool initiallyEnabled = true);
53  ~IdleEvent();
54 
55  //\}
56  //-////////////////////////////////////////////////////////////////////////
57 
58  void disable();
59  void enable();
60 
61  void action(Callback const & cb);
62 
63  protected:
64 
65  private:
66  virtual void v_run();
67  virtual char const * v_type() const;
68  virtual std::string v_info() const;
69 
70  Callback cb_;
71 
72  friend class detail::IdleEventDispatcher;
73  };
74 
75 }}
76 
77 //-/////////////////////////////////////////////////////////////////////////////////////////////////
78 #include "IdleEvent.cci"
79 //#include "IdleEvent.ct"
80 //#include "IdleEvent.cti"
81 #endif
82 
83 
84 // Local Variables:
85 // mode: c++
86 // fill-column: 100
87 // comment-column: 40
88 // c-file-style: "senf"
89 // indent-tabs-mode: nil
90 // ispell-local-dictionary: "american"
91 // compile-command: "scons -u test"
92 // End:
FIFORunner public header.
boost::function< void()> Callback
Definition: IdleEvent.hh:45
boost::intrusive::list_base_hook< boost::intrusive::tag< IdleEventListTag > > IdleEventListBase
Definition: IdleEvent.hh:32