Skip to content

Commit

Permalink
SchedulerPostTask: Reuse original TaskController (#27595)
Browse files Browse the repository at this point in the history
## Summary

It's not clear to me why we currently create a new TaskController in
`runTask` – ultimately, we use the same signal and priority from the
original created in `unstable_scheduleCallback`

## How did you test this change?
```
yarn test SchedulerPostTask
```

DiffTrain build for [a17467e](a17467e)
  • Loading branch information
noahlemen committed Nov 2, 2023
1 parent 2d0b5da commit 63e0697
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 68 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6bfc0e032acc7e5ad6da2a09f3c4f47f3321da2c
a17467e7e2cd8947c595d1834889b5d184459f12
6 changes: 3 additions & 3 deletions compiled/facebook-www/ReactDOM-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -16781,7 +16781,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1840 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-modern-327d25fe",
version: "18.3.0-www-modern-9cbf42e3",
rendererPackageName: "react-dom"
};
(function (internals) {
Expand Down Expand Up @@ -16826,7 +16826,7 @@ var devToolsConfig$jscomp$inline_1840 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-modern-327d25fe"
reconcilerVersion: "18.3.0-www-modern-9cbf42e3"
});
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
exports.createPortal = function (children, container) {
Expand Down Expand Up @@ -17078,7 +17078,7 @@ exports.useFormState = function () {
exports.useFormStatus = function () {
throw Error(formatProdErrorMessage(248));
};
exports.version = "18.3.0-www-modern-327d25fe";
exports.version = "18.3.0-www-modern-9cbf42e3";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
10 changes: 2 additions & 8 deletions compiled/facebook-www/SchedulerPostTask-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,9 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
if (typeof result === "function") {
// Assume this is a continuation
var continuation = result;
var continuationController = new TaskController({
priority: postTaskPriority
});
var continuationOptions = {
signal: continuationController.signal
}; // Update the original callback node's controller, since even though we're
// posting a new task, conceptually it's the same one.

node._controller = continuationController;
signal: node._controller.signal
};
var nextTask = runTask.bind(
null,
priorityLevel,
Expand Down
10 changes: 2 additions & 8 deletions compiled/facebook-www/SchedulerPostTask-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,9 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
if (typeof result === "function") {
// Assume this is a continuation
var continuation = result;
var continuationController = new TaskController({
priority: postTaskPriority
});
var continuationOptions = {
signal: continuationController.signal
}; // Update the original callback node's controller, since even though we're
// posting a new task, conceptually it's the same one.

node._controller = continuationController;
signal: node._controller.signal
};
var nextTask = runTask.bind(
null,
priorityLevel,
Expand Down
20 changes: 8 additions & 12 deletions compiled/facebook-www/SchedulerPostTask-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
currentPriorityLevel_DEPRECATED = priorityLevel;
var result = callback(!1);
if ("function" === typeof result) {
var continuationController = new TaskController({
priority: postTaskPriority
}),
continuationOptions = { signal: continuationController.signal };
node._controller = continuationController;
var nextTask = runTask.bind(
null,
priorityLevel,
postTaskPriority,
node,
result
);
var continuationOptions = { signal: node._controller.signal },
nextTask = runTask.bind(
null,
priorityLevel,
postTaskPriority,
node,
result
);
void 0 !== scheduler.yield
? scheduler
.yield(continuationOptions)
Expand Down
20 changes: 8 additions & 12 deletions compiled/facebook-www/SchedulerPostTask-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
currentPriorityLevel_DEPRECATED = priorityLevel;
var result = callback(!1);
if ("function" === typeof result) {
var continuationController = new TaskController({
priority: postTaskPriority
}),
continuationOptions = { signal: continuationController.signal };
node._controller = continuationController;
var nextTask = runTask.bind(
null,
priorityLevel,
postTaskPriority,
node,
result
);
var continuationOptions = { signal: node._controller.signal },
nextTask = runTask.bind(
null,
priorityLevel,
postTaskPriority,
node,
result
);
void 0 !== scheduler.yield
? scheduler
.yield(continuationOptions)
Expand Down
20 changes: 8 additions & 12 deletions compiled/facebook-www/SchedulerPostTask-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
currentPriorityLevel_DEPRECATED = priorityLevel;
var result = callback(!1);
if ("function" === typeof result) {
var continuationController = new TaskController({
priority: postTaskPriority
}),
continuationOptions = { signal: continuationController.signal };
node._controller = continuationController;
var nextTask = runTask.bind(
null,
priorityLevel,
postTaskPriority,
node,
result
);
var continuationOptions = { signal: node._controller.signal },
nextTask = runTask.bind(
null,
priorityLevel,
postTaskPriority,
node,
result
);
void 0 !== scheduler.yield
? scheduler
.yield(continuationOptions)
Expand Down
20 changes: 8 additions & 12 deletions compiled/facebook-www/SchedulerPostTask-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@ function runTask(priorityLevel, postTaskPriority, node, callback) {
currentPriorityLevel_DEPRECATED = priorityLevel;
var result = callback(!1);
if ("function" === typeof result) {
var continuationController = new TaskController({
priority: postTaskPriority
}),
continuationOptions = { signal: continuationController.signal };
node._controller = continuationController;
var nextTask = runTask.bind(
null,
priorityLevel,
postTaskPriority,
node,
result
);
var continuationOptions = { signal: node._controller.signal },
nextTask = runTask.bind(
null,
priorityLevel,
postTaskPriority,
node,
result
);
void 0 !== scheduler.yield
? scheduler
.yield(continuationOptions)
Expand Down

0 comments on commit 63e0697

Please sign in to comment.