Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Scheduler / TimerSource.hh
1 // $Id$
2 //
3 // Copyright (C) 2009
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief TimerSource public header */
25
26 #ifndef HH_SENF_Scheduler_TimerSource_
27 #define HH_SENF_Scheduler_TimerSource_ 1
28
29 // Custom includes
30 #include <boost/utility.hpp>
31 #include <signal.h>
32 #include "ClockService.hh"
33 #include "FdManager.hh"
34
35 //#include "TimerSource.mpp"
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37
38 namespace senf {
39 namespace scheduler {
40 namespace detail {
41
42     class TimerSource
43         : boost::noncopyable
44     {
45     public:
46         virtual ~TimerSource();
47
48         virtual void timeout(ClockService::clock_type timeout) = 0;
49         virtual void notimeout() = 0;
50
51         virtual void enable() = 0;
52         virtual void disable() = 0;
53
54     protected:
55         TimerSource();
56     };
57
58     class POSIXTimerSource
59         : public detail::FdManager::Event, public TimerSource
60     {
61     public:
62         POSIXTimerSource();
63         ~POSIXTimerSource();
64
65         virtual void timeout(ClockService::clock_type timeout);
66         virtual void notimeout();
67
68         virtual void enable();
69         virtual void disable();
70
71     private:
72         static void sigHandler(int signal, ::siginfo_t * siginfo, void *);
73         virtual void signal(int events);
74         void reschedule();
75
76         bool timeoutEnabled_;
77         ClockService::clock_type timeout_;
78         int timerPipe_[2];
79         sigset_t sigSet_;
80         bool signalEnabled_;
81         timer_t timerId_;
82     };
83
84     class PollTimerSource
85         : public TimerSource
86     {
87     public:
88         virtual void timeout(ClockService::clock_type timeout);
89         virtual void notimeout();
90
91         virtual void enable();
92         virtual void disable();
93     };
94
95 #ifdef HAVE_TIMERFD_CREATE
96     class TimerFDTimerSource
97         : public detail::FdManager::Event, public TimerSource
98     {
99     public:
100         TimerFDTimerSource();
101         ~TimerFDTimerSource();
102
103         virtual void timeout(ClockService::clock_type timeout);
104         virtual void notimeout();
105
106         virtual void enable();
107         virtual void disable();
108
109         static bool haveTimerFD();
110
111     private:
112         virtual void signal(int events);
113         void reschedule();
114
115         int timerfd_;
116         bool timeoutEnabled_;
117         ClockService::clock_type timeout_;
118     };
119 #endif
120
121 }}}
122
123 //-/////////////////////////////////////////////////////////////////////////////////////////////////
124 #include "TimerSource.cci"
125 //#include "TimerSource.ct"
126 //#include "TimerSource.cti"
127 #endif
128
129 \f
130 // Local Variables:
131 // mode: c++
132 // fill-column: 100
133 // comment-column: 40
134 // c-file-style: "senf"
135 // indent-tabs-mode: nil
136 // ispell-local-dictionary: "american"
137 // compile-command: "scons -u test"
138 // End: