diff options
| author | Dana Jansens <danakj@orodu.net> | 2002-11-03 12:48:10 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2002-11-03 12:48:10 +0000 |
| commit | 373de009f7e98b0c6f3a78f31c1e5c120cd722ed (patch) | |
| tree | a3aaa153b9704083a6bcfd07732c27d3e204c5b5 /src/timer.hh | |
| parent | c5f62494f14629797c109acc0b3048203a1adb6a (diff) | |
new timers, timer manager
Diffstat (limited to 'src/timer.hh')
| -rw-r--r-- | src/timer.hh | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/timer.hh b/src/timer.hh index 2eb5065f..774d0e49 100644 --- a/src/timer.hh +++ b/src/timer.hh @@ -29,20 +29,19 @@ public: virtual void timeout(void) = 0; }; -class BTimer { +class OBTimer { private: - OBTimerQueueManager *manager; TimeoutHandler *handler; bool timing, recur; timeval _start, _timeout; - BTimer(const BTimer&); - BTimer& operator=(const BTimer&); + OBTimer(const OBTimer&); + OBTimer& operator=(const OBTimer&); public: - BTimer(OBTimerQueueManager *m, TimeoutHandler *h); - virtual ~BTimer(void); + OBTimer(TimeoutHandler *h); + virtual ~OBTimer(void); void fireTimeout(void); @@ -65,7 +64,7 @@ public: void stop(void); // manager releases timer void halt(void); // halts the timer - bool operator<(const BTimer& other) const + bool operator<(const OBTimer& other) const { return shouldFire(other.endpoint()); } }; @@ -95,12 +94,13 @@ private: }; struct TimerLessThan { - bool operator()(const BTimer* const l, const BTimer* const r) const { + bool operator()(const OBTimer* const l, const OBTimer* const r) const { return *r < *l; } }; -typedef _timer_queue<BTimer*, std::vector<BTimer*>, TimerLessThan> TimerQueue; +typedef _timer_queue<OBTimer*, + std::vector<OBTimer*>, TimerLessThan> TimerQueue; class OBTimerQueueManager { private: @@ -108,11 +108,15 @@ private: public: OBTimerQueueManager() {} virtual ~OBTimerQueueManager() {} + + //! Will wait for and fire the next timer in the queue. + /*! + The function will stop waiting if an event is received from the X server. + */ + virtual void fire(); - virtual void go(); - - virtual void addTimer(BTimer* timer); - virtual void removeTimer(BTimer* timer); + virtual void addTimer(OBTimer* timer); + virtual void removeTimer(OBTimer* timer); }; } |
