* Constructor for the Timer class.
*/
Timer::Timer(void)
- : m_Interval(0), m_Next(0)
+ : m_Interval(0), m_Next(0), m_Started(false), m_Running(false)
{ }
/**
Timer::~Timer(void)
{
Stop();
+
+ boost::mutex::scoped_lock lock(l_TimerMutex);
+ while (m_Running)
+ l_TimerCV.wait(lock);
}
/**
throw;
}
+ {
+ boost::mutex::scoped_lock lock(l_TimerMutex);
+ m_Running = false;
+ l_TimerCV.notify_all();
+ }
+
Reschedule();
+
}
/**
void Timer::Reschedule(double next)
{
ASSERT(!OwnsLock());
+ ASSERT(!m_Running);
boost::mutex::scoped_lock lock(l_TimerMutex);
* until the current call is completed. */
l_Timers.erase(timer);
+ timer->m_Running = true;
+
lock.unlock();
/* Asynchronously call the timer. */
double m_Interval; /**< The interval of the timer. */
double m_Next; /**< When the next event should happen. */
bool m_Started; /**< Whether the timer is enabled. */
+ bool m_Running; /**< Whether the timer proc is currently running. */
void Call();