@@ -134,7 +134,7 @@ class Timer::TimerThread final : private Thread
134134 break ;
135135
136136 auto * timer = first.timer ;
137- first.countdownMs = timer->timerPeriodMs ;
137+ first.countdownMs = timer->getTimerInterval () ;
138138 shuffleTimerBackInQueue (0 );
139139 notify ();
140140
@@ -175,7 +175,7 @@ class Timer::TimerThread final : private Thread
175175
176176 auto pos = timers.size ();
177177
178- timers.push_back ({ t, t->timerPeriodMs });
178+ timers.push_back ({ t, t->getTimerInterval () });
179179 t->positionInQueue = pos;
180180 shuffleTimerForwardInQueue (pos);
181181 notify ();
@@ -210,7 +210,7 @@ class Timer::TimerThread final : private Thread
210210 jassert (timers[pos].timer == t);
211211
212212 auto lastCountdown = timers[pos].countdownMs ;
213- auto newCountdown = t->timerPeriodMs ;
213+ auto newCountdown = t->getTimerInterval () ;
214214
215215 if (newCountdown != lastCountdown)
216216 {
@@ -350,10 +350,7 @@ void Timer::startTimer (int interval) noexcept
350350
351351 if (auto * instance = TimerThread::getInstance ())
352352 {
353- bool wasStopped = (timerPeriodMs == 0 );
354- timerPeriodMs = jmax (1 , interval);
355-
356- if (wasStopped)
353+ if (timerPeriodMs.exchange (jmax (1 , interval)) == 0 )
357354 instance->addTimer (this );
358355 else
359356 instance->resetTimerCounter (this );
0 commit comments