]>
Dogcows Code - chaz/openbox/blob - timerqueuemanager.cc
e5f0a7418fdaba834165e48073e020b555bcde55
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 TimerQueueManager::fire(bool wait
)
15 timeval now
, tm
, *timeout
= (timeval
*) 0;
17 const int xfd
= ConnectionNumber(**display
);
20 FD_SET(xfd
, &rfds
); // break on any x events
23 if (! timerList
.empty()) {
24 const Timer
* const timer
= timerList
.top();
26 gettimeofday(&now
, 0);
27 tm
= timer
->remainingTime(now
);
32 select(xfd
+ 1, &rfds
, 0, 0, timeout
);
35 // check for timer timeout
36 gettimeofday(&now
, 0);
38 // there is a small chance for deadlock here:
39 // *IF* the timer list keeps getting refreshed *AND* the time between
40 // timer->start() and timer->shouldFire() is within the timer's period
41 // then the timer will keep firing. This should be VERY near impossible.
42 while (! timerList
.empty()) {
43 Timer
*timer
= timerList
.top();
44 if (! timer
->shouldFire(now
))
50 if (timer
->recurring())
56 void TimerQueueManager::addTimer(Timer
*timer
)
59 timerList
.push(timer
);
62 void TimerQueueManager::removeTimer(Timer
* timer
)
65 timerList
.release(timer
);
This page took 0.034068 seconds and 3 git commands to generate.