MCPcopy
hub / github.com/react/react / advanceTimers

Function advanceTimers

packages/scheduler/src/forks/Scheduler.js:103–125  ·  view source on GitHub ↗
(currentTime: number)

Source from the content-addressed store, hash-verified

101 typeof setImmediate !== 'undefined' ? setImmediate : null; // IE and Node.js + jsdom
102
103function advanceTimers(currentTime: number) {
104 // Check for tasks that are no longer delayed and add them to the queue.
105 let timer = peek(timerQueue);
106 while (timer !== null) {
107 if (timer.callback === null) {
108 // Timer was cancelled.
109 pop(timerQueue);
110 } else if (timer.startTime <= currentTime) {
111 // Timer fired. Transfer to the task queue.
112 pop(timerQueue);
113 timer.sortIndex = timer.expirationTime;
114 push(taskQueue, timer);
115 if (enableProfiling) {
116 markTaskStart(timer, currentTime);
117 timer.isQueued = true;
118 }
119 } else {
120 // Remaining timers are pending.
121 return;
122 }
123 timer = peek(timerQueue);
124 }
125}
126
127function handleTimeout(currentTime: number) {
128 isHostTimeoutScheduled = false;

Callers 2

handleTimeoutFunction · 0.70
workLoopFunction · 0.70

Calls 4

peekFunction · 0.90
popFunction · 0.90
pushFunction · 0.90
markTaskStartFunction · 0.90

Tested by

no test coverage detected