mirror of https://github.com/Icinga/icinga2.git
Timer: actually support non-periodic timers
This commit is contained in:
parent
3933502739
commit
298f3b1973
|
@ -168,7 +168,7 @@ void Timer::Start()
|
|||
InitializeThread();
|
||||
}
|
||||
|
||||
InternalRescheduleUnlocked(false);
|
||||
InternalRescheduleUnlocked(false, m_Interval > 0 ? -1 : m_Next);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -251,7 +251,7 @@ double Timer::GetNext() const
|
|||
}
|
||||
|
||||
/**
|
||||
* Adjusts all timers by adding the specified amount of time to their
|
||||
* Adjusts all periodic timers by adding the specified amount of time to their
|
||||
* next scheduled timestamp.
|
||||
*
|
||||
* @param adjustment The adjustment.
|
||||
|
@ -268,6 +268,11 @@ void Timer::AdjustTimers(double adjustment)
|
|||
std::vector<Timer *> timers;
|
||||
|
||||
for (Timer *timer : idx) {
|
||||
/* Don't schedule the next call if this is not a periodic timer. */
|
||||
if (timer->m_Interval <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (std::fabs(now - (timer->m_Next + adjustment)) <
|
||||
std::fabs(now - timer->m_Next)) {
|
||||
timer->m_Next += adjustment;
|
||||
|
|
Loading…
Reference in New Issue