From bc4ea1a66f91e1ec323e5ce0be46bf2aa941f405 Mon Sep 17 00:00:00 2001 From: Anthony Nicholls Date: Fri, 9 May 2025 14:38:01 +0100 Subject: [PATCH] HighResolutionTimer: Prevent a race condition in the unit tests --- modules/juce_core/threads/juce_HighResolutionTimer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/juce_core/threads/juce_HighResolutionTimer.cpp b/modules/juce_core/threads/juce_HighResolutionTimer.cpp index d9b755fafa..17736afc76 100644 --- a/modules/juce_core/threads/juce_HighResolutionTimer.cpp +++ b/modules/juce_core/threads/juce_HighResolutionTimer.cpp @@ -366,6 +366,7 @@ public: beginBehaviourTest ("A timer can be restarted externally, after being stopped internally"); { + WaitableEvent stopTimer; WaitableEvent timerStopped; WaitableEvent timerFiredAfterRestart; @@ -374,6 +375,7 @@ public: switch (++callbackCount) { case 1: + stopTimer.wait (maximumTimeoutMs); timer.stopTimer(); timerStopped.signal(); return; @@ -391,6 +393,7 @@ public: timer.startTimer (1); expect (timer.isTimerRunning()); + stopTimer.signal(); expect (timerStopped.wait (maximumTimeoutMs)); expect (! timer.isTimerRunning());