]>
Dogcows Code - chaz/openbox/blob - otk/timerqueuemanager.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
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
->remainingTime(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
))
48 if (timer
->recurring())
54 void OBTimerQueueManager::addTimer(OBTimer
*timer
)
57 timerList
.push(timer
);
60 void OBTimerQueueManager::removeTimer(OBTimer
* timer
)
63 timerList
.release(timer
);
This page took 0.0348579999999999 seconds and 4 git commands to generate.