Skip to content

Commit bc4ea1a

Browse files
HighResolutionTimer: Prevent a race condition in the unit tests
1 parent 980926d commit bc4ea1a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

modules/juce_core/threads/juce_HighResolutionTimer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ class HighResolutionTimerTests final : public UnitTest
366366

367367
beginBehaviourTest ("A timer can be restarted externally, after being stopped internally");
368368
{
369+
WaitableEvent stopTimer;
369370
WaitableEvent timerStopped;
370371
WaitableEvent timerFiredAfterRestart;
371372

@@ -374,6 +375,7 @@ class HighResolutionTimerTests final : public UnitTest
374375
switch (++callbackCount)
375376
{
376377
case 1:
378+
stopTimer.wait (maximumTimeoutMs);
377379
timer.stopTimer();
378380
timerStopped.signal();
379381
return;
@@ -391,6 +393,7 @@ class HighResolutionTimerTests final : public UnitTest
391393
timer.startTimer (1);
392394
expect (timer.isTimerRunning());
393395

396+
stopTimer.signal();
394397
expect (timerStopped.wait (maximumTimeoutMs));
395398
expect (! timer.isTimerRunning());
396399

0 commit comments

Comments
 (0)