Merge bdb5444ab5
into 4b877b6c66
This commit is contained in:
commit
3fd987c49d
|
@ -162,7 +162,7 @@ function handleTimeout(currentTime: number) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function flushWork(hasTimeRemaining: boolean, initialTime: number) {
|
function flushWork(initialTime: number) {
|
||||||
if (enableProfiling) {
|
if (enableProfiling) {
|
||||||
markSchedulerUnsuspended(initialTime);
|
markSchedulerUnsuspended(initialTime);
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ function flushWork(hasTimeRemaining: boolean, initialTime: number) {
|
||||||
try {
|
try {
|
||||||
if (enableProfiling) {
|
if (enableProfiling) {
|
||||||
try {
|
try {
|
||||||
return workLoop(hasTimeRemaining, initialTime);
|
return workLoop(initialTime);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (currentTask !== null) {
|
if (currentTask !== null) {
|
||||||
const currentTime = getCurrentTime();
|
const currentTime = getCurrentTime();
|
||||||
|
@ -193,7 +193,7 @@ function flushWork(hasTimeRemaining: boolean, initialTime: number) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No catch in prod code path.
|
// No catch in prod code path.
|
||||||
return workLoop(hasTimeRemaining, initialTime);
|
return workLoop(initialTime);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
currentTask = null;
|
currentTask = null;
|
||||||
|
@ -206,7 +206,7 @@ function flushWork(hasTimeRemaining: boolean, initialTime: number) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function workLoop(hasTimeRemaining: boolean, initialTime: number) {
|
function workLoop(initialTime: number) {
|
||||||
let currentTime = initialTime;
|
let currentTime = initialTime;
|
||||||
advanceTimers(currentTime);
|
advanceTimers(currentTime);
|
||||||
currentTask = peek(taskQueue);
|
currentTask = peek(taskQueue);
|
||||||
|
@ -214,10 +214,7 @@ function workLoop(hasTimeRemaining: boolean, initialTime: number) {
|
||||||
currentTask !== null &&
|
currentTask !== null &&
|
||||||
!(enableSchedulerDebugging && isSchedulerPaused)
|
!(enableSchedulerDebugging && isSchedulerPaused)
|
||||||
) {
|
) {
|
||||||
if (
|
if (currentTask.expirationTime > currentTime && shouldYieldToHost()) {
|
||||||
currentTask.expirationTime > currentTime &&
|
|
||||||
(!hasTimeRemaining || shouldYieldToHost())
|
|
||||||
) {
|
|
||||||
// This currentTask hasn't expired, and we've reached the deadline.
|
// This currentTask hasn't expired, and we've reached the deadline.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -467,10 +464,7 @@ function unstable_getCurrentPriorityLevel(): PriorityLevel {
|
||||||
let isMessageLoopRunning = false;
|
let isMessageLoopRunning = false;
|
||||||
let scheduledHostCallback:
|
let scheduledHostCallback:
|
||||||
| null
|
| null
|
||||||
| ((
|
| ((initialTime: DOMHighResTimeStamp | number) => boolean) = null;
|
||||||
hasTimeRemaining: boolean,
|
|
||||||
initialTime: DOMHighResTimeStamp | number,
|
|
||||||
) => boolean) = null;
|
|
||||||
let taskTimeoutID: TimeoutID = (-1: any);
|
let taskTimeoutID: TimeoutID = (-1: any);
|
||||||
|
|
||||||
// Scheduler periodically yields in case there is other work on the main
|
// Scheduler periodically yields in case there is other work on the main
|
||||||
|
@ -567,7 +561,6 @@ const performWorkUntilDeadline = () => {
|
||||||
// Keep track of the start time so we can measure how long the main thread
|
// Keep track of the start time so we can measure how long the main thread
|
||||||
// has been blocked.
|
// has been blocked.
|
||||||
startTime = currentTime;
|
startTime = currentTime;
|
||||||
const hasTimeRemaining = true;
|
|
||||||
|
|
||||||
// If a scheduler task throws, exit the current browser task so the
|
// If a scheduler task throws, exit the current browser task so the
|
||||||
// error can be observed.
|
// error can be observed.
|
||||||
|
@ -578,7 +571,7 @@ const performWorkUntilDeadline = () => {
|
||||||
let hasMoreWork = true;
|
let hasMoreWork = true;
|
||||||
try {
|
try {
|
||||||
// $FlowFixMe[not-a-function] found when upgrading Flow
|
// $FlowFixMe[not-a-function] found when upgrading Flow
|
||||||
hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
|
hasMoreWork = scheduledHostCallback(currentTime);
|
||||||
} finally {
|
} finally {
|
||||||
if (hasMoreWork) {
|
if (hasMoreWork) {
|
||||||
// If there's more work, schedule the next message event at the end
|
// If there's more work, schedule the next message event at the end
|
||||||
|
|
Loading…
Reference in New Issue