requestHostCallback
requestHostCallback starts the host callback loop when Scheduler has ready work to process.
function requestHostCallback() {
if (!isMessageLoopRunning) {
isMessageLoopRunning = true;
schedulePerformWorkUntilDeadline();
}
}
Scheduler does not run workLoop directly when a task is scheduled. It posts a host callback so work can run in a later event cycle.
isMessageLoopRunning
isMessageLoopRunning prevents duplicate host callbacks.
If it is false, there is no active Scheduler message loop. requestHostCallback sets it to true and schedules performWorkUntilDeadline.
If it is already true, Scheduler has either posted a host callback or is already processing work. In that case, there is no need to post another one.
What Happens Next
schedulePerformWorkUntilDeadline chooses the best available host API, such as setImmediate, MessageChannel, or setTimeout, and uses it to call performWorkUntilDeadline.
So this function is small, but it is the switch that turns Scheduler from idle into active work processing.