From: Dana Jansens Date: Tue, 14 Jan 2003 21:14:21 +0000 (+0000) Subject: no long used with our Timer-ng! X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=231f4dadabd532183317188c1a0e8ffe87dc579b;p=chaz%2Fopenbox no long used with our Timer-ng! --- diff --git a/otk/timerqueue.hh b/otk/timerqueue.hh deleted file mode 100644 index 5a531ebe..00000000 --- a/otk/timerqueue.hh +++ /dev/null @@ -1,51 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- -#ifndef __timerqueue_hh -#define __timerqueue_hh - -#ifndef DOXYGEN_IGNORE - -#include "timer.hh" - -#include -#include -#include - -namespace otk { - -template -class _timer_queue: protected std::priority_queue<_Tp, _Sequence, _Compare> { -public: - typedef std::priority_queue<_Tp, _Sequence, _Compare> _Base; - - _timer_queue(): _Base() {} - ~_timer_queue() {} - - void release(const _Tp& value) { - c.erase(std::remove(c.begin(), c.end(), value), c.end()); - // after removing the item we need to make the heap again - std::make_heap(c.begin(), c.end(), comp); - } - bool empty() const { return _Base::empty(); } - size_t size() const { return _Base::size(); } - void push(const _Tp& value) { _Base::push(value); } - void pop() { _Base::pop(); } - const _Tp& top() const { return _Base::top(); } -private: - // no copying! - _timer_queue(const _timer_queue&) {} - _timer_queue& operator=(const _timer_queue&) {} -}; - -struct TimerLessThan { - bool operator()(const Timer* const l, const Timer* const r) const { - return *r < *l; - } -}; - -typedef _timer_queue, TimerLessThan> TimerQueue; - -} - -#endif // DOXYGEN_IGNORE - -#endif // __timerqueue_hh diff --git a/otk/timerqueuemanager.cc b/otk/timerqueuemanager.cc deleted file mode 100644 index e5f0a741..00000000 --- a/otk/timerqueuemanager.cc +++ /dev/null @@ -1,68 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- - -#ifdef HAVE_CONFIG_H -# include "../config.h" -#endif // HAVE_CONFIG_H - -#include "timerqueuemanager.hh" -#include "display.hh" - -namespace otk { - -void TimerQueueManager::fire(bool wait) -{ - fd_set rfds; - timeval now, tm, *timeout = (timeval *) 0; - - const int xfd = ConnectionNumber(**display); - - FD_ZERO(&rfds); - FD_SET(xfd, &rfds); // break on any x events - - if (wait) { - if (! timerList.empty()) { - const Timer* const timer = timerList.top(); - - gettimeofday(&now, 0); - tm = timer->remainingTime(now); - - timeout = &tm; - } - - select(xfd + 1, &rfds, 0, 0, timeout); - } - - // check for timer timeout - gettimeofday(&now, 0); - - // there is a small chance for deadlock here: - // *IF* the timer list keeps getting refreshed *AND* the time between - // timer->start() and timer->shouldFire() is within the timer's period - // then the timer will keep firing. This should be VERY near impossible. - while (! timerList.empty()) { - Timer *timer = timerList.top(); - if (! timer->shouldFire(now)) - break; - - timerList.pop(); - - timer->fire(); - if (timer->recurring()) - timer->start(); - } -} - - -void TimerQueueManager::addTimer(Timer *timer) -{ - assert(timer); - timerList.push(timer); -} - -void TimerQueueManager::removeTimer(Timer* timer) -{ - assert(timer); - timerList.release(timer); -} - -} diff --git a/otk/timerqueuemanager.hh b/otk/timerqueuemanager.hh deleted file mode 100644 index 042ede4c..00000000 --- a/otk/timerqueuemanager.hh +++ /dev/null @@ -1,46 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- -#ifndef __timerqueuemanager_hh -#define __timerqueuemanager_hh - -#include "timerqueue.hh" - -namespace otk { - -//! Manages a queue of Timer objects -/*! - All Timer objects add themself to a TimerQueueManager. The manager is - what fires the timers when their time has elapsed. This is done by having the - application call the TimerQueueManager::fire class in its main event loop. -*/ -class TimerQueueManager { -private: - //! A priority queue of all timers being managed by this class. - TimerQueue timerList; -public: - //! Constructs a new TimerQueueManager - TimerQueueManager() {} - //! Destroys the TimerQueueManager - virtual ~TimerQueueManager() {} - - //! Fire the next timer in the queue. - /*! - @param wait If true, this function will wait for the next timer, breaking - on any events from the X server. - */ - virtual void fire(bool wait = true); - - //! Adds a new timer to the queue - /*! - @param timer An Timer to add to the queue - */ - virtual void addTimer(Timer* timer); - //! Removes a timer from the queue - /*! - @param timer An Timer already in the queue to remove - */ - virtual void removeTimer(Timer* timer); -}; - -} - -#endif // __timerqueuemanager_hh