Support multiple redundant Timer#Start() calls

so that only the first one changes l_AliveTimers (as in Timer#Stop()).
This commit is contained in:
Alexander A. Klimov 2023-04-03 17:35:16 +02:00
parent 298f3b1973
commit c41e5fd05d

View File

@ -162,12 +162,13 @@ double Timer::GetInterval() const
void Timer::Start() void Timer::Start()
{ {
std::unique_lock<std::mutex> lock(l_TimerMutex); std::unique_lock<std::mutex> lock(l_TimerMutex);
m_Started = true;
if (++l_AliveTimers == 1) { if (!m_Started && ++l_AliveTimers == 1) {
InitializeThread(); InitializeThread();
} }
m_Started = true;
InternalRescheduleUnlocked(false, m_Interval > 0 ? -1 : m_Next); InternalRescheduleUnlocked(false, m_Interval > 0 ? -1 : m_Next);
} }