mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added a safety mechanism for pathological cases where user code that repeatedly blocks in a timer callback could get the event loop stuck
This commit is contained in:
parent
b010df5bcd
commit
15d746cf6e
1 changed files with 6 additions and 0 deletions
|
|
@ -92,6 +92,9 @@ public:
|
|||
|
||||
void callTimers()
|
||||
{
|
||||
// avoid getting stuck in a loop if a timer callback repeatedly takes too long
|
||||
const uint32 timeout = Time::getMillisecondCounter() + 100;
|
||||
|
||||
const LockType::ScopedLockType sl (lock);
|
||||
|
||||
while (firstTimer != nullptr && firstTimer->timerCountdownMs <= 0)
|
||||
|
|
@ -109,6 +112,9 @@ public:
|
|||
t->timerCallback();
|
||||
}
|
||||
JUCE_CATCH_EXCEPTION
|
||||
|
||||
if (Time::getMillisecondCounter() > timeout)
|
||||
break;
|
||||
}
|
||||
|
||||
callbackArrived.signal();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue