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:
parent
5a0dde4915
commit
e607b15388
1 changed files with 4 additions and 17 deletions
|
|
@ -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)
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue