MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / IsCycleComplete

Function IsCycleComplete

source/application.cpp:1465–1488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1463
1464
1465ResultType IsCycleComplete(int aSleepDuration, DWORD aStartTime, bool aAllowEarlyReturn)
1466// This function is used just to make MsgSleep() more readable/understandable.
1467{
1468 // Note: Even if TickCount has wrapped due to system being up more than about 49 days,
1469 // DWORD subtraction still gives the right answer as long as aStartTime itself isn't more
1470 // than about 49 days ago. Note: must cast to int or any negative result will be lost
1471 // due to DWORD type:
1472 DWORD tick_now = GetTickCount();
1473 if (!aAllowEarlyReturn && (int)(aSleepDuration - (tick_now - aStartTime)) > SLEEP_INTERVAL_HALF)
1474 // Early return isn't allowed and the time remaining is large enough that we need to
1475 // wait some more (small amounts of remaining time can't be effectively waited for
1476 // due to the 10ms granularity limit of SetTimer):
1477 return FAIL; // Tell the caller to wait some more.
1478
1479 // v1.0.38.04: Reset mLastPeekTime because caller has just done a GetMessage() or PeekMessage(),
1480 // both of which should have routed events to the keyboard/mouse hooks like LONG_OPERATION_UPDATE's
1481 // PeekMessage() and thus satisfied the reason that mLastPeekTime is tracked in the first place.
1482 // UPDATE: Although the hooks now have a dedicated thread, there's a good chance mLastPeekTime is
1483 // beneficial in terms of increasing GUI & script responsiveness, so it is kept.
1484 // The following might also improve performance slightly by avoiding extra Peek() calls, while also
1485 // reducing premature thread interruptions.
1486 g_script.mLastPeekTime = tick_now;
1487 return OK;
1488}
1489
1490
1491

Callers 1

MsgSleepFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected