]>
Dogcows Code - chaz/openbox/blob - otk/timerqueuemanager.cc
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
4 # include "../config.h"
5 #endif // HAVE_CONFIG_H
7 #include "timerqueuemanager.hh"
12 void OBTimerQueueManager::fire()
15 timeval now
, tm
, *timeout
= (timeval
*) 0;
17 const int xfd
= ConnectionNumber(otk::OBDisplay::display
);
20 FD_SET(xfd
, &rfds
); // break on any x events
22 if (! timerList
.empty()) {
23 const OBTimer
* const timer
= timerList
.top();
25 gettimeofday(&now
, 0);
26 tm
= timer
->timeRemaining(now
);
31 select(xfd
+ 1, &rfds
, 0, 0, timeout
);
33 // check for timer timeout
34 gettimeofday(&now
, 0);
36 // there is a small chance for deadlock here:
37 // *IF* the timer list keeps getting refreshed *AND* the time between
38 // timer->start() and timer->shouldFire() is within the timer's period
39 // then the timer will keep firing. This should be VERY near impossible.
40 while (! timerList
.empty()) {
41 OBTimer
*timer
= timerList
.top();
42 if (! timer
->shouldFire(now
))
49 if (timer
->isRecurring())
55 void OBTimerQueueManager::addTimer(OBTimer
*timer
)
58 timerList
.push(timer
);
61 void OBTimerQueueManager::removeTimer(OBTimer
* timer
)
64 timerList
.release(timer
);
This page took 0.037075 seconds and 5 git commands to generate.