mirror of https://github.com/Icinga/icinga2.git
Timer#Start(): don't unnecessarily unlock/lock l_TimerMutex
via new Timer#InternalRescheduleUnlocked()
This commit is contained in:
parent
13b9cfda41
commit
3933502739
|
@ -161,16 +161,14 @@ double Timer::GetInterval() const
|
|||
*/
|
||||
void Timer::Start()
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(l_TimerMutex);
|
||||
m_Started = true;
|
||||
std::unique_lock<std::mutex> lock(l_TimerMutex);
|
||||
m_Started = true;
|
||||
|
||||
if (++l_AliveTimers == 1) {
|
||||
InitializeThread();
|
||||
}
|
||||
if (++l_AliveTimers == 1) {
|
||||
InitializeThread();
|
||||
}
|
||||
|
||||
InternalReschedule(false);
|
||||
InternalRescheduleUnlocked(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -202,6 +200,13 @@ void Timer::Reschedule(double next)
|
|||
InternalReschedule(false, next);
|
||||
}
|
||||
|
||||
void Timer::InternalReschedule(bool completed, double next)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock (l_TimerMutex);
|
||||
|
||||
InternalRescheduleUnlocked(completed, next);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reschedules this timer.
|
||||
*
|
||||
|
@ -209,10 +214,8 @@ void Timer::Reschedule(double next)
|
|||
* @param next The time when this timer should be called again. Use -1 to let
|
||||
* the timer figure out a suitable time based on the interval.
|
||||
*/
|
||||
void Timer::InternalReschedule(bool completed, double next)
|
||||
void Timer::InternalRescheduleUnlocked(bool completed, double next)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(l_TimerMutex);
|
||||
|
||||
if (completed)
|
||||
m_Running = false;
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ private:
|
|||
Timer() = default;
|
||||
void Call();
|
||||
void InternalReschedule(bool completed, double next = -1);
|
||||
void InternalRescheduleUnlocked(bool completed, double next = -1);
|
||||
|
||||
static void TimerThreadProc();
|
||||
|
||||
|
|
Loading…
Reference in New Issue