insertTimer(this);
}
-void Timer::repeat() {
+void Timer::repeat(int timeoutMs_) {
timeval now;
gettimeofday(&now, 0);
if (msBetween(&lastDueTime, &dueTime) != 0)
vlog.error("Timer incorrectly modified whilst repeating");
+ if (timeoutMs_ != -1)
+ timeoutMs = timeoutMs_;
+
dueTime = addMillis(lastDueTime, timeoutMs);
if (isBefore(now)) {
// Time has jumped forwards, or we're not getting enough
// Restarts the timer in a way that repeats that last timeout.
// This allows you to have a periodic timer without the risk of
// accumulating drift caused by processing delays.
- void repeat();
+ // A new interval can be specified, otherwise the previous
+ // interval is reused.
+ void repeat(int timeoutMs_=-1);
// stop()
// Cancels the timer.
writeUpdate();
// If this is the first iteration then we need to adjust the timeout
- if (frameTimer.getTimeoutMs() != 1000/rfb::Server::frameRate)
- frameTimer.start(1000/rfb::Server::frameRate);
- else
- frameTimer.repeat();
+ frameTimer.repeat(1000/rfb::Server::frameRate);
} else if (t == &idleTimer) {
slog.info("MaxIdleTime reached, exiting");
desktop->terminate();