Skip to content

Commit

Permalink
Renaming method names from "pending work" to "pending priority"
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite committed May 9, 2018
1 parent 2ffb544 commit 0717641
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 37 deletions.
18 changes: 8 additions & 10 deletions packages/react-reconciler/src/ReactFiberPendingPriority.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {enableSuspense} from 'shared/ReactFeatureFlags';

// TODO: Offscreen updates

export function addPendingWork(
export function addPendingPriorityLevel(
root: FiberRoot,
expirationTime: ExpirationTime,
): void {
Expand All @@ -41,7 +41,7 @@ export function addPendingWork(
}
}

export function flushPendingWork(
export function flushPendingPriorityLevel(
root: FiberRoot,
currentTime: ExpirationTime,
earliestRemainingTime: ExpirationTime,
Expand Down Expand Up @@ -81,7 +81,7 @@ export function flushPendingWork(
if (earliestSuspendedTime === NoWork) {
// There's no suspended work. Treat the earliest remaining level as a
// pending level.
addPendingWork(root, earliestRemainingTime);
addPendingPriorityLevel(root, earliestRemainingTime);
return;
}

Expand All @@ -95,14 +95,14 @@ export function flushPendingWork(

// There's no suspended work. Treat the earliest remaining level as a
// pending level.
addPendingWork(root, earliestRemainingTime);
addPendingPriorityLevel(root, earliestRemainingTime);
return;
}

if (earliestRemainingTime < earliestSuspendedTime) {
// The earliest remaining time is earlier than all the suspended work.
// Treat it as a pending update.
addPendingWork(root, earliestRemainingTime);
addPendingPriorityLevel(root, earliestRemainingTime);
return;
}

Expand All @@ -111,7 +111,7 @@ export function flushPendingWork(
}
}

export function suspendPendingWork(
export function suspendPriorityLevel(
root: FiberRoot,
suspendedTime: ExpirationTime,
): void {
Expand Down Expand Up @@ -157,7 +157,7 @@ export function suspendPendingWork(
}
}

export function resumePendingWork(
export function resumePriorityLevel(
root: FiberRoot,
pingedTime: ExpirationTime,
): void {
Expand Down Expand Up @@ -187,9 +187,7 @@ export function resumePendingWork(
}
}

export function findNextExpirationTimeToWorkOn(
root: FiberRoot,
): ExpirationTime {
export function findNextPendingPriorityLevel(root: FiberRoot): ExpirationTime {
if (enableSuspense) {
const earliestSuspendedTime = root.earliestSuspendedTime;
const earliestPendingTime = root.earliestPendingTime;
Expand Down
47 changes: 20 additions & 27 deletions packages/react-reconciler/src/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ import ReactFiberHydrationContext from './ReactFiberHydrationContext';
import ReactFiberInstrumentation from './ReactFiberInstrumentation';
import ReactDebugCurrentFiber from './ReactDebugCurrentFiber';
import {
addPendingWork,
flushPendingWork,
findNextExpirationTimeToWorkOn,
suspendPendingWork,
resumePendingWork,
addPendingPriorityLevel,
flushPendingPriorityLevel,
findNextPendingPriorityLevel,
suspendPriorityLevel,
resumePriorityLevel,
} from './ReactFiberPendingPriority';
import {
recordEffect,
Expand Down Expand Up @@ -260,7 +260,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
let nextRoot: FiberRoot | null = null;
// The time at which we're currently rendering work.
let nextRenderExpirationTime: ExpirationTime = NoWork;
let nextEarliestTimeoutMs: number = -1;
let nextLatestTimeoutMs: number = -1;
let nextRenderIsExpired: boolean = false;

// The next fiber with an effect that we're currently committing.
Expand Down Expand Up @@ -358,7 +358,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(

nextRoot = null;
nextRenderExpirationTime = NoWork;
nextEarliestTimeoutMs = -1;
nextLatestTimeoutMs = -1;
nextRenderIsExpired = false;
nextUnitOfWork = null;

Expand Down Expand Up @@ -684,8 +684,8 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
ReactFiberInstrumentation.debugTool.onCommitWork(finishedWork);
}

flushPendingWork(root, currentTime, root.current.expirationTime);
const remainingTime = findNextExpirationTimeToWorkOn(root);
flushPendingPriorityLevel(root, currentTime, root.current.expirationTime);
const remainingTime = findNextPendingPriorityLevel(root);
if (remainingTime === NoWork) {
// If there's no remaining work, we can clear the set of already failed
// error boundaries.
Expand Down Expand Up @@ -970,7 +970,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
resetStack();
nextRoot = root;
nextRenderExpirationTime = expirationTime;
nextEarliestTimeoutMs = -1;
nextLatestTimeoutMs = -1;
nextUnitOfWork = createWorkInProgress(
nextRoot.current,
null,
Expand Down Expand Up @@ -1067,15 +1067,13 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
'Expired work should have completed. This error is likely caused ' +
'by a bug in React. Please file an issue.',
);
suspendPendingWork(root, expirationTime);
if (nextEarliestTimeoutMs >= 0) {
suspendPriorityLevel(root, expirationTime);
if (nextLatestTimeoutMs >= 0) {
setTimeout(() => {
retrySuspendedRoot(root, expirationTime);
}, nextEarliestTimeoutMs);
}, nextLatestTimeoutMs);
}
const firstUnblockedExpirationTime = findNextExpirationTimeToWorkOn(
root,
);
const firstUnblockedExpirationTime = findNextPendingPriorityLevel(root);
onBlock(firstUnblockedExpirationTime);
return null;
}
Expand Down Expand Up @@ -1254,17 +1252,14 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
suspendedTime: ExpirationTime,
) {
// Schedule the timeout.
if (
timeoutMs >= 0 &&
(nextEarliestTimeoutMs === -1 || timeoutMs < nextEarliestTimeoutMs)
) {
nextEarliestTimeoutMs = timeoutMs;
if (timeoutMs >= 0 && nextLatestTimeoutMs < timeoutMs) {
nextLatestTimeoutMs = timeoutMs;
}
}

function retrySuspendedRoot(root, suspendedTime) {
resumePendingWork(root, suspendedTime);
const retryTime = findNextExpirationTimeToWorkOn(root);
resumePriorityLevel(root, suspendedTime);
const retryTime = findNextPendingPriorityLevel(root);
if (retryTime !== NoWork) {
requestRetry(root, retryTime);
}
Expand Down Expand Up @@ -1310,10 +1305,8 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
interruptedBy = fiber;
resetStack();
}
addPendingWork(root, expirationTime);
const nextExpirationTimeToWorkOn = findNextExpirationTimeToWorkOn(
root,
);
addPendingPriorityLevel(root, expirationTime);
const nextExpirationTimeToWorkOn = findNextPendingPriorityLevel(root);
if (
// If we're in the render phase, we don't need to schedule this root
// for an update, because we'll do it before we exit...
Expand Down

0 comments on commit 0717641

Please sign in to comment.