while (!_q.empty()) {
curr = _q.top();
- /* since we overload the destructor to keep from removing from the middle of
- the priority queue, set _del_me, we have to do our real delete in here.
+ /* since we overload the destructor to keep from removing from the middle
+ of the priority queue, set _del_me, we have to do our real delete in
+ here.
*/
if (curr->_del_me) {
_q.pop();
curr->_action(curr->_data);
timevalAdd(curr->_timeout, curr->_delay);
_q.push(curr);
+
+ /* if at least one timer fires, then don't wait on X events, as there may
+ already be some in the queue from the timer callbacks.
+ */
+ wait = false;
}
if (wait) {
fd = ConnectionNumber(**display);
FD_ZERO(&selset);
FD_SET(fd, &selset);
- if (nearestTimeout(next))
+ if (nearestTimeout(next)) {
select(fd + 1, &selset, NULL, NULL, &next);
- else
+ } else
select(fd + 1, &selset, NULL, NULL, NULL);
}
}