X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Ftimerqueuemanager.cc;h=1d6b50ce8ece5e9d86b8ea5943fe0adc256b70c0;hb=bd39de609bcd340dd00fa9dab1519ee2a3aac458;hp=0d7d4983be51646a973620ed532ab3550f0519f5;hpb=b0a532db8adeb909fa2cd8e518ca6917a2d7df0a;p=chaz%2Fopenbox diff --git a/otk/timerqueuemanager.cc b/otk/timerqueuemanager.cc index 0d7d4983..1d6b50ce 100644 --- a/otk/timerqueuemanager.cc +++ b/otk/timerqueuemanager.cc @@ -1,4 +1,4 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- +// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- #ifdef HAVE_CONFIG_H # include "../config.h" @@ -9,27 +9,29 @@ namespace otk { -void OBTimerQueueManager::fire() +void TimerQueueManager::fire(bool wait) { fd_set rfds; timeval now, tm, *timeout = (timeval *) 0; - const int xfd = ConnectionNumber(otk::OBDisplay::display); + const int xfd = ConnectionNumber(Display::display); FD_ZERO(&rfds); FD_SET(xfd, &rfds); // break on any x events - if (! timerList.empty()) { - const OBTimer* const timer = timerList.top(); - - gettimeofday(&now, 0); - tm = timer->timeRemaining(now); - - timeout = &tm; + 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); } - select(xfd + 1, &rfds, 0, 0, timeout); - // check for timer timeout gettimeofday(&now, 0); @@ -38,27 +40,26 @@ void OBTimerQueueManager::fire() // 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()) { - OBTimer *timer = timerList.top(); + Timer *timer = timerList.top(); if (! timer->shouldFire(now)) break; timerList.pop(); - timer->fireTimeout(); - timer->halt(); - if (timer->isRecurring()) + timer->fire(); + if (timer->recurring()) timer->start(); } } -void OBTimerQueueManager::addTimer(OBTimer *timer) +void TimerQueueManager::addTimer(Timer *timer) { assert(timer); timerList.push(timer); } -void OBTimerQueueManager::removeTimer(OBTimer* timer) +void TimerQueueManager::removeTimer(Timer* timer) { assert(timer); timerList.release(timer);