MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / invokeExpiredTimers

Method invokeExpiredTimers

Libraries/Async/Async.cpp:1337–1370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1335SC::AsyncLoopTimeout* SC::AsyncEventLoop::Internal::findEarliestLoopTimeout() const { return activeLoopTimeouts.front; }
1336
1337void SC::AsyncEventLoop::Internal::invokeExpiredTimers(AsyncEventLoop& eventLoop, TimeMs currentTime)
1338{
1339 AsyncLoopTimeout* async = activeLoopTimeouts.front;
1340 while (async != nullptr)
1341 {
1342 AsyncLoopTimeout* current = async;
1343 async = static_cast<AsyncLoopTimeout*>(async->next);
1344 if (currentTime.milliseconds >= current->expirationTime.milliseconds)
1345 {
1346 removeActiveHandle(*current);
1347 Result res(true);
1348 AsyncLoopTimeout::Result result(eventLoop, *current, res);
1349 if (current->callback.isValid())
1350 {
1351 current->callback(result);
1352 }
1353
1354 if (async != nullptr and not async->isActive())
1355 {
1356 // Our "next" timeout to check could have been Cancelled during the callback
1357 // and it could be in the submission queue now.
1358 // It's possible detecting this case by checking the active state.
1359 // In this case it makes sense to re-check the entire active timers list.
1360 async = activeLoopTimeouts.front;
1361 SC_ASYNC_ASSERT_DEBUG(async == nullptr or async->isActive()); // Should not be possible
1362 }
1363 }
1364 else
1365 {
1366 // Timers are ordered by expirationTime so we can safely break out of this loop
1367 break;
1368 }
1369 }
1370}
1371
1372template <typename T>
1373void SC::AsyncEventLoop::Internal::stopRequests(AsyncEventLoop& eventLoop, IntrusiveDoubleLinkedList<T>& linkedList)

Callers

nothing calls this directly

Calls 2

isValidMethod · 0.45
isActiveMethod · 0.45

Tested by

no test coverage detected