FdManager.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_FdManager_
18 #define HH_SENF_Scheduler_FdManager_ 1
19 
20 // Custom includes
21 #include "Poller.hh"
22 #include "ClockService.hh"
23 #include <senf/Utils/singleton.hh>
25 
26 //#include "FdManager.mpp"
27 //-/////////////////////////////////////////////////////////////////////////////////////////////////
28 
29 namespace senf {
30 namespace scheduler {
31 
32  void restart();
33 
34 namespace detail {
35 
36  class FdManager
37  : public singleton<FdManager>
38  {
39  public:
41  struct Event {
42  virtual ~Event();
43  virtual void signal(int events) = 0;
44  };
45 
46  enum Events {
49  };
50 
53 
54  bool set(int fd, int events, Event * entry);
55  void remove(int fd);
56 
57  // Called by FileDispatcher
58  void timeout(int t);
59  int timeout() const;
60 
61  void processOnce();
62 
64  ClockService::clock_type const & eventTime() const;
65  CyclicTimestamp const & eventTimestamp() const;
66 
67  protected:
68 
69  private:
70  FdManager();
71 
72  Poller<Event> poller_;
73  ClockService::clock_type eventTime_;
74  CyclicTimestamp eventTimestamp_;
75 
76  friend void senf::scheduler::restart();
77  friend class singleton<FdManager>;
78  };
79 
80 }}}
81 
82 //-/////////////////////////////////////////////////////////////////////////////////////////////////
83 #include "FdManager.cci"
84 //#include "FdManager.ct"
85 //#include "FdManager.cti"
86 #endif
87 
88 
89 // Local Variables:
90 // mode: c++
91 // fill-column: 100
92 // comment-column: 40
93 // c-file-style: "senf"
94 // indent-tabs-mode: nil
95 // ispell-local-dictionary: "american"
96 // compile-command: "scons -u test"
97 // End:
config::time_type clock_type
ClockService timer data type.
Definition: ClockService.hh:78
CyclicTimestamp const & eventTimestamp() const
Cyclic Timestamp of last event (1ms precision)
ClockService::clock_type const & eventTime() const
Time of last event.
virtual void signal(int events)=0
Called when the given event is posted.
void restart()
Restart scheduler.
Definition: Scheduler.cc:96
void processOnce()
Wait for events.
Definition: FdManager.cc:26
ClockService public header.
Epoll abstraction.
Definition: Poller.hh:42
Poller public header.