MCPcopy Create free account
hub / github.com/microsoft/SandDance / unstable_scheduleCallback

Function unstable_scheduleCallback

docs/external/js/react.development.js:2753–2822  ·  view source on GitHub ↗
(priorityLevel, callback, options)

Source from the content-addressed store, hash-verified

2751 }
2752
2753 function unstable_scheduleCallback(priorityLevel, callback, options) {
2754 var currentTime = getCurrentTime();
2755 var startTime;
2756 var timeout;
2757
2758 if (typeof options === 'object' && options !== null) {
2759 var delay = options.delay;
2760
2761 if (typeof delay === 'number' && delay > 0) {
2762 startTime = currentTime + delay;
2763 } else {
2764 startTime = currentTime;
2765 }
2766
2767 timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel);
2768 } else {
2769 timeout = timeoutForPriorityLevel(priorityLevel);
2770 startTime = currentTime;
2771 }
2772
2773 var expirationTime = startTime + timeout;
2774 var newTask = {
2775 id: taskIdCounter++,
2776 callback: callback,
2777 priorityLevel: priorityLevel,
2778 startTime: startTime,
2779 expirationTime: expirationTime,
2780 sortIndex: -1
2781 };
2782
2783 {
2784 newTask.isQueued = false;
2785 }
2786
2787 if (startTime > currentTime) {
2788 // This is a delayed task.
2789 newTask.sortIndex = startTime;
2790 push(timerQueue, newTask);
2791
2792 if (peek(taskQueue) === null && newTask === peek(timerQueue)) {
2793 // All tasks are delayed, and this is the task with the earliest delay.
2794 if (isHostTimeoutScheduled) {
2795 // Cancel an existing timeout.
2796 cancelHostTimeout();
2797 } else {
2798 isHostTimeoutScheduled = true;
2799 } // Schedule a timeout.
2800
2801
2802 requestHostTimeout(handleTimeout, startTime - currentTime);
2803 }
2804 } else {
2805 newTask.sortIndex = expirationTime;
2806 push(taskQueue, newTask);
2807
2808 {
2809 markTaskStart(newTask, currentTime);
2810 newTask.isQueued = true;

Callers 1

Calls 5

getCurrentTimeFunction · 0.85
timeoutForPriorityLevelFunction · 0.85
markTaskStartFunction · 0.85
pushFunction · 0.70
peekFunction · 0.70

Tested by

no test coverage detected