Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Source/Task/TaskQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,14 @@ bool TaskQueuePortImpl::ArmTimerForNextPendingDueTime(
// must re-evaluate instead of resurrecting it.
bool TaskQueuePortImpl::RearmTimerIfDueTimeUnchanged(uint64_t dueTime)
{
// UINT64_MAX is the "nothing armed" sentinel and must never be programmed
// as a real deadline (see SubmitPendingCallbacks). Mirrors the guard in
// ArmTimerIfEarlier.
if (dueTime == UINT64_MAX)
{
return true;
}

while (true)
{
uint64_t currentDue = m_timerDue.load();
Expand Down Expand Up @@ -1402,6 +1410,17 @@ void TaskQueuePortImpl::SubmitPendingCallbacks()
{
uint64_t dueTime = m_timerDue.load();

// UINT64_MAX is the "nothing armed" sentinel. It must never be programmed
// as a real deadline: WaitTimer::Start(UINT64_MAX) converts to a duration
// of -1 (before the steady_clock epoch), a perpetually-past deadline that
// fires immediately and re-arms the sentinel in an infinite loop, starving
// every real pending callback. If the timer is disarmed there is nothing
// to sweep, so return.
if (dueTime == UINT64_MAX)
{
return;
}

// Timer callbacks are advisory: a threadpool fire can arrive after
// retargeting, or slightly before the steady-clock deadline due to
// clock-source differences on Win32. If the deadline hasn't arrived,
Expand Down