mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 07:04:37 +02:00
parent
9567cd663b
commit
d397933eff
@ -49,7 +49,7 @@ static TimerSet l_Timers;
|
|||||||
* Constructor for the Timer class.
|
* Constructor for the Timer class.
|
||||||
*/
|
*/
|
||||||
Timer::Timer(void)
|
Timer::Timer(void)
|
||||||
: m_Interval(0), m_Next(0)
|
: m_Interval(0), m_Next(0), m_Started(false), m_Running(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,6 +58,10 @@ Timer::Timer(void)
|
|||||||
Timer::~Timer(void)
|
Timer::~Timer(void)
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
|
boost::mutex::scoped_lock lock(l_TimerMutex);
|
||||||
|
while (m_Running)
|
||||||
|
l_TimerCV.wait(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,7 +104,14 @@ void Timer::Call(void)
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(l_TimerMutex);
|
||||||
|
m_Running = false;
|
||||||
|
l_TimerCV.notify_all();
|
||||||
|
}
|
||||||
|
|
||||||
Reschedule();
|
Reschedule();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -172,6 +183,7 @@ void Timer::Stop(void)
|
|||||||
void Timer::Reschedule(double next)
|
void Timer::Reschedule(double next)
|
||||||
{
|
{
|
||||||
ASSERT(!OwnsLock());
|
ASSERT(!OwnsLock());
|
||||||
|
ASSERT(!m_Running);
|
||||||
|
|
||||||
boost::mutex::scoped_lock lock(l_TimerMutex);
|
boost::mutex::scoped_lock lock(l_TimerMutex);
|
||||||
|
|
||||||
@ -280,6 +292,8 @@ void Timer::TimerThreadProc(void)
|
|||||||
* until the current call is completed. */
|
* until the current call is completed. */
|
||||||
l_Timers.erase(timer);
|
l_Timers.erase(timer);
|
||||||
|
|
||||||
|
timer->m_Running = true;
|
||||||
|
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
/* Asynchronously call the timer. */
|
/* Asynchronously call the timer. */
|
||||||
|
@ -81,6 +81,7 @@ private:
|
|||||||
double m_Interval; /**< The interval of the timer. */
|
double m_Interval; /**< The interval of the timer. */
|
||||||
double m_Next; /**< When the next event should happen. */
|
double m_Next; /**< When the next event should happen. */
|
||||||
bool m_Started; /**< Whether the timer is enabled. */
|
bool m_Started; /**< Whether the timer is enabled. */
|
||||||
|
bool m_Running; /**< Whether the timer proc is currently running. */
|
||||||
|
|
||||||
void Call();
|
void Call();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user