1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

Timer: Always ensure the timer thread is started

This commit is contained in:
Anthony Nicholls 2024-04-11 10:54:05 +00:00
parent 5a0dde4915
commit e607b15388

View file

@ -23,8 +23,7 @@
namespace juce
{
class Timer::TimerThread final : private Thread,
private AsyncUpdater
class Timer::TimerThread final : private Thread
{
public:
using LockType = CriticalSection; // (mysteriously, using a SpinLock here causes problems on some XP machines..)
@ -32,12 +31,10 @@ public:
TimerThread() : Thread ("JUCE Timer")
{
timers.reserve (32);
triggerAsyncUpdate();
}
~TimerThread() override
{
cancelPendingUpdate();
signalThreadShouldExit();
callbackArrived.signal();
stopThread (-1);
@ -121,14 +118,6 @@ public:
void callTimersSynchronously()
{
if (! isThreadRunning())
{
// (This is relied on by some plugins in cases where the MM has
// had to restart and the async callback never started)
cancelPendingUpdate();
triggerAsyncUpdate();
}
callTimers();
}
@ -136,6 +125,9 @@ public:
{
const LockType::ScopedLockType sl (lock);
if (! isThreadRunning())
startThread (Thread::Priority::high);
// Trying to add a timer that's already here - shouldn't get to this point,
// so if you get this assertion, let me know!
jassert (std::none_of (timers.begin(), timers.end(),
@ -281,11 +273,6 @@ private:
return timers.front().countdownMs;
}
void handleAsyncUpdate() override
{
startThread (Priority::high);
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TimerThread)
};