diff options
Diffstat (limited to 'src/Timer.hh')
-rw-r--r-- | src/Timer.hh | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/src/Timer.hh b/src/Timer.hh index bf79f4f..873aaef 100644 --- a/src/Timer.hh +++ b/src/Timer.hh | |||
@@ -34,8 +34,8 @@ | |||
34 | */ | 34 | */ |
35 | class TimeoutHandler { | 35 | class TimeoutHandler { |
36 | public: | 36 | public: |
37 | /// called when the time is out | 37 | /// called when the time is out |
38 | virtual void timeout() = 0; | 38 | virtual void timeout() = 0; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | /** | 41 | /** |
@@ -43,47 +43,47 @@ public: | |||
43 | */ | 43 | */ |
44 | class BTimer { | 44 | class BTimer { |
45 | public: | 45 | public: |
46 | explicit BTimer(TimeoutHandler *handler); | 46 | explicit BTimer(TimeoutHandler *handler); |
47 | virtual ~BTimer(); | 47 | virtual ~BTimer(); |
48 | 48 | ||
49 | inline int isTiming() const { return m_timing; } | 49 | inline int isTiming() const { return m_timing; } |
50 | inline int doOnce() const { return m_once; } | 50 | inline int doOnce() const { return m_once; } |
51 | 51 | ||
52 | inline const timeval &getTimeout() const { return m_timeout; } | 52 | inline const timeval &getTimeout() const { return m_timeout; } |
53 | inline const timeval &getStartTime() const { return m_start; } | 53 | inline const timeval &getStartTime() const { return m_start; } |
54 | 54 | ||
55 | inline void fireOnce(bool once) { m_once = once; } | 55 | inline void fireOnce(bool once) { m_once = once; } |
56 | /// set timeout | 56 | /// set timeout |
57 | void setTimeout(long val); | 57 | void setTimeout(long val); |
58 | /// set timeout | 58 | /// set timeout |
59 | void setTimeout(timeval val); | 59 | void setTimeout(timeval val); |
60 | /// start timing | 60 | /// start timing |
61 | void start(); | 61 | void start(); |
62 | /// stop timing | 62 | /// stop timing |
63 | void stop(); | 63 | void stop(); |
64 | /// update all timers | 64 | /// update all timers |
65 | static void updateTimers(int file_descriptor); | 65 | static void updateTimers(int file_descriptor); |
66 | 66 | ||
67 | protected: | 67 | protected: |
68 | /// force a timeout | 68 | /// force a timeout |
69 | void fireTimeout(); | 69 | void fireTimeout(); |
70 | 70 | ||
71 | private: | 71 | private: |
72 | /// add a timer to the static list | 72 | /// add a timer to the static list |
73 | static void addTimer(BTimer *timer); | 73 | static void addTimer(BTimer *timer); |
74 | /// remove a timer from the static list | 74 | /// remove a timer from the static list |
75 | static void removeTimer(BTimer *timer); | 75 | static void removeTimer(BTimer *timer); |
76 | 76 | ||
77 | typedef std::list<BTimer *> TimerList; | 77 | typedef std::list<BTimer *> TimerList; |
78 | static TimerList m_timerlist; ///< list of all timers | 78 | static TimerList m_timerlist; ///< list of all timers |
79 | 79 | ||
80 | TimeoutHandler *m_handler; ///< handler | 80 | TimeoutHandler *m_handler; ///< handler |
81 | 81 | ||
82 | bool m_timing; ///< clock running? | 82 | bool m_timing; ///< clock running? |
83 | bool m_once; ///< do timeout only once? | 83 | bool m_once; ///< do timeout only once? |
84 | 84 | ||
85 | timeval m_start; ///< start time | 85 | timeval m_start; ///< start time |
86 | timeval m_timeout; ///< time length | 86 | timeval m_timeout; ///< time length |
87 | 87 | ||
88 | }; | 88 | }; |
89 | 89 | ||