From e607b1538828d7088b90b890db4437ae2cf30ef6 Mon Sep 17 00:00:00 2001 From: Anthony Nicholls Date: Thu, 11 Apr 2024 10:54:05 +0000 Subject: [PATCH] Timer: Always ensure the timer thread is started --- modules/juce_events/timers/juce_Timer.cpp | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/modules/juce_events/timers/juce_Timer.cpp b/modules/juce_events/timers/juce_Timer.cpp index 0fee2b5be4..10430f91f7 100644 --- a/modules/juce_events/timers/juce_Timer.cpp +++ b/modules/juce_events/timers/juce_Timer.cpp @@ -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) };