IdleEvent.ih
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 
14 /** \file
15  \brief IdleEvent internal header */
16 
17 #ifndef IH_SENF_Scheduler_IdleEvent_
18 #define IH_SENF_Scheduler_IdleEvent_ 1
19 
20 // Custom includes
21 #include <senf/Utils/singleton.hh>
22 
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 namespace senf {
26 namespace scheduler {
27 
28  void restart();
29 
30 namespace detail {
31 
32  class IdleEventDispatcher
33  : public singleton<IdleEventDispatcher>
34  {
35  public:
36  using singleton<IdleEventDispatcher>::instance;
37  using singleton<IdleEventDispatcher>::alive;
38 
39  void add(IdleEvent & event);
40  void remove(IdleEvent & event);
41 
42  void prepareRun();
43 
44  // Called by PollTimerSource
45  void timeout(int t);
46  int timeout() const;
47 
48  bool empty() const;
49 
50  private:
51  IdleEventDispatcher();
52  ~IdleEventDispatcher();
53 
54  typedef boost::intrusive::list< IdleEvent,
55  boost::intrusive::constant_time_size<false>,
56  boost::intrusive::base_hook<IdleEventListBase> > EventList;
57 
58  EventList events_;
59  int managerTimeout_;
60 
61  friend void senf::scheduler::restart();
62  friend class singleton<IdleEventDispatcher>;
63  };
64 
65 }}}
66 
67 //-/////////////////////////////////////////////////////////////////////////////////////////////////
68 #endif
69 
70 
71 // Local Variables:
72 // mode: c++
73 // fill-column: 100
74 // comment-column: 40
75 // c-file-style: "senf"
76 // indent-tabs-mode: nil
77 // ispell-local-dictionary: "american"
78 // compile-command: "scons -u test"
79 // End: