MCPcopy Create free account
hub / github.com/reactjs/react-rails / workLoop

Function workLoop

lib/assets/react-source/development/react.js:3409–3464  ·  view source on GitHub ↗
(hasTimeRemaining, initialTime)

Source from the content-addressed store, hash-verified

3407 }
3408
3409 function workLoop(hasTimeRemaining, initialTime) {
3410 var currentTime = initialTime;
3411 advanceTimers(currentTime);
3412 currentTask = peek(taskQueue);
3413
3414 while (currentTask !== null && !(enableSchedulerDebugging )) {
3415 if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) {
3416 // This currentTask hasn't expired, and we've reached the deadline.
3417 break;
3418 }
3419
3420 var callback = currentTask.callback;
3421
3422 if (callback !== null) {
3423 currentTask.callback = null;
3424 currentPriorityLevel = currentTask.priorityLevel;
3425 var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
3426 markTaskRun(currentTask, currentTime);
3427 var continuationCallback = callback(didUserCallbackTimeout);
3428 currentTime = exports.unstable_now();
3429
3430 if (typeof continuationCallback === 'function') {
3431 currentTask.callback = continuationCallback;
3432 markTaskYield(currentTask, currentTime);
3433 } else {
3434 {
3435 markTaskCompleted(currentTask, currentTime);
3436 currentTask.isQueued = false;
3437 }
3438
3439 if (currentTask === peek(taskQueue)) {
3440 pop(taskQueue);
3441 }
3442 }
3443
3444 advanceTimers(currentTime);
3445 } else {
3446 pop(taskQueue);
3447 }
3448
3449 currentTask = peek(taskQueue);
3450 } // Return whether there's additional work
3451
3452
3453 if (currentTask !== null) {
3454 return true;
3455 } else {
3456 var firstTimer = peek(timerQueue);
3457
3458 if (firstTimer !== null) {
3459 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
3460 }
3461
3462 return false;
3463 }
3464 }
3465
3466 function unstable_runWithPriority(priorityLevel, eventHandler) {

Callers 1

flushWorkFunction · 0.85

Calls 6

advanceTimersFunction · 0.85
markTaskRunFunction · 0.85
markTaskYieldFunction · 0.85
markTaskCompletedFunction · 0.85
popFunction · 0.85
peekFunction · 0.70

Tested by

no test coverage detected