| 1335 | SC::AsyncLoopTimeout* SC::AsyncEventLoop::Internal::findEarliestLoopTimeout() const { return activeLoopTimeouts.front; } |
| 1336 | |
| 1337 | void 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 | |
| 1372 | template <typename T> |
| 1373 | void SC::AsyncEventLoop::Internal::stopRequests(AsyncEventLoop& eventLoop, IntrusiveDoubleLinkedList<T>& linkedList) |