File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -582,6 +582,15 @@ void SC::AsyncEventLoop::Internal::invokeExpiredTimers(Time::HighResolutionCount
582
582
submissions.queueBack (*current);
583
583
numberOfSubmissions += 1 ;
584
584
}
585
+ if (async != nullptr and not async->isActive ())
586
+ {
587
+ // Our "next" timeout to check could have been Cancelled during the callback
588
+ // and it could be in the submission queue now.
589
+ // It's possible detecting this case by checking the active state.
590
+ // In this case it makes sense to re-check the entire active timers list.
591
+ async = activeLoopTimeouts.front ;
592
+ SC_ASSERT_DEBUG (async == nullptr or async->isActive ()); // Should not be possible
593
+ }
585
594
}
586
595
}
587
596
}
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ void SC::AsyncTest::loopTimeout()
11
11
int timeout2Called = 0 ;
12
12
timeout1.callback = [&](AsyncLoopTimeout::Result& res)
13
13
{
14
- SC_TEST_EXPECT (res.getAsync ().relativeTimeout . ms == 1 );
14
+ SC_TEST_EXPECT (res.getAsync ().relativeTimeout == 1_ms );
15
15
SC_TEST_EXPECT (res.getAsync ().isFree ());
16
16
SC_TEST_EXPECT (not res.getAsync ().isActive ());
17
17
SC_TEST_EXPECT (not res.getAsync ().isCancelling ());
@@ -27,11 +27,11 @@ void SC::AsyncTest::loopTimeout()
27
27
SC_TEST_EXPECT (not res.getAsync ().isActive ());
28
28
res.reactivateRequest (true );
29
29
SC_TEST_EXPECT (res.getAsync ().isActive ());
30
- res.getAsync ().relativeTimeout = Time::Milliseconds ( 1 ) ;
30
+ res.getAsync ().relativeTimeout = 1_ms ;
31
31
}
32
32
timeout2Called++;
33
33
};
34
- SC_TEST_EXPECT (timeout2.start (eventLoop, Time::Milliseconds ( 100 ) ));
34
+ SC_TEST_EXPECT (timeout2.start (eventLoop, 100_ms ));
35
35
SC_TEST_EXPECT (eventLoop.runOnce ());
36
36
SC_TEST_EXPECT (timeout1Called == 1 and timeout2Called == 0 ); // timeout1 fires after 1 ms
37
37
SC_TEST_EXPECT (eventLoop.runOnce ());
You can’t perform that action at this time.
0 commit comments