MCPcopy
hub / github.com/facebook/react / flushWork

Function flushWork

packages/scheduler/src/forks/Scheduler.js:144–186  ·  view source on GitHub ↗
(initialTime: number)

Source from the content-addressed store, hash-verified

142}
143
144function flushWork(initialTime: number) {
145 if (enableProfiling) {
146 markSchedulerUnsuspended(initialTime);
147 }
148
149 // We'll need a host callback the next time work is scheduled.
150 isHostCallbackScheduled = false;
151 if (isHostTimeoutScheduled) {
152 // We scheduled a timeout but it's no longer needed. Cancel it.
153 isHostTimeoutScheduled = false;
154 cancelHostTimeout();
155 }
156
157 isPerformingWork = true;
158 const previousPriorityLevel = currentPriorityLevel;
159 try {
160 if (enableProfiling) {
161 try {
162 return workLoop(initialTime);
163 } catch (error) {
164 if (currentTask !== null) {
165 const currentTime = getCurrentTime();
166 // $FlowFixMe[incompatible-call] found when upgrading Flow
167 markTaskErrored(currentTask, currentTime);
168 // $FlowFixMe[incompatible-use] found when upgrading Flow
169 currentTask.isQueued = false;
170 }
171 throw error;
172 }
173 } else {
174 // No catch in prod code path.
175 return workLoop(initialTime);
176 }
177 } finally {
178 currentTask = null;
179 currentPriorityLevel = previousPriorityLevel;
180 isPerformingWork = false;
181 if (enableProfiling) {
182 const currentTime = getCurrentTime();
183 markSchedulerSuspended(currentTime);
184 }
185 }
186}
187
188function workLoop(initialTime: number) {
189 let currentTime = initialTime;

Callers 1

performWorkUntilDeadlineFunction · 0.70

Calls 6

markSchedulerUnsuspendedFunction · 0.90
markTaskErroredFunction · 0.90
markSchedulerSuspendedFunction · 0.90
cancelHostTimeoutFunction · 0.70
workLoopFunction · 0.70
getCurrentTimeFunction · 0.70

Tested by

no test coverage detected