(hasTimeRemaining, initialTime)
| 2609 | } |
| 2610 | |
| 2611 | function workLoop(hasTimeRemaining, initialTime) { |
| 2612 | var currentTime = initialTime; |
| 2613 | advanceTimers(currentTime); |
| 2614 | currentTask = peek(taskQueue); |
| 2615 | |
| 2616 | while (currentTask !== null && !(enableSchedulerDebugging )) { |
| 2617 | if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) { |
| 2618 | // This currentTask hasn't expired, and we've reached the deadline. |
| 2619 | break; |
| 2620 | } |
| 2621 | |
| 2622 | var callback = currentTask.callback; |
| 2623 | |
| 2624 | if (callback !== null) { |
| 2625 | currentTask.callback = null; |
| 2626 | currentPriorityLevel = currentTask.priorityLevel; |
| 2627 | var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; |
| 2628 | markTaskRun(currentTask, currentTime); |
| 2629 | var continuationCallback = callback(didUserCallbackTimeout); |
| 2630 | currentTime = getCurrentTime(); |
| 2631 | |
| 2632 | if (typeof continuationCallback === 'function') { |
| 2633 | currentTask.callback = continuationCallback; |
| 2634 | markTaskYield(currentTask, currentTime); |
| 2635 | } else { |
| 2636 | { |
| 2637 | markTaskCompleted(currentTask, currentTime); |
| 2638 | currentTask.isQueued = false; |
| 2639 | } |
| 2640 | |
| 2641 | if (currentTask === peek(taskQueue)) { |
| 2642 | pop(taskQueue); |
| 2643 | } |
| 2644 | } |
| 2645 | |
| 2646 | advanceTimers(currentTime); |
| 2647 | } else { |
| 2648 | pop(taskQueue); |
| 2649 | } |
| 2650 | |
| 2651 | currentTask = peek(taskQueue); |
| 2652 | } // Return whether there's additional work |
| 2653 | |
| 2654 | |
| 2655 | if (currentTask !== null) { |
| 2656 | return true; |
| 2657 | } else { |
| 2658 | var firstTimer = peek(timerQueue); |
| 2659 | |
| 2660 | if (firstTimer !== null) { |
| 2661 | requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); |
| 2662 | } |
| 2663 | |
| 2664 | return false; |
| 2665 | } |
| 2666 | } |
| 2667 | |
| 2668 | function unstable_runWithPriority(priorityLevel, eventHandler) { |
no test coverage detected
searching dependent graphs…