(hasTimeRemaining: boolean, initialTime: number)
| 142 | } |
| 143 | |
| 144 | function flushWork(hasTimeRemaining: boolean, 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(hasTimeRemaining, 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(hasTimeRemaining, 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 | |
| 188 | function workLoop(hasTimeRemaining: boolean, initialTime: number): boolean { |
| 189 | let currentTime = initialTime; |
nothing calls this directly
no test coverage detected